Skip to content

Conversation

@yamanahlawat
Copy link

Tool Injection via MCP Elicitation

Adds tool injection capability to mcp-run-python, enabling external tools to be dynamically injected into Python execution environments via MCP elicitation protocol.

Changes

  • Tool Injection: tool_injection.py module for dynamic tool function injection into Python globals
  • MCP Tools: Added discover_available_tools tool and enhanced run_python_code with tool injection
  • PydanticAI Extension: mcp_run_python/ext/pydantic_ai.py with create_tool_elicitation_callback() for PydanticAI toolsets

Usage

from mcp_run_python.ext import create_tool_elicitation_callback
callback = create_tool_elicitation_callback(toolset=my_toolset)
# Use callback with MCPServerStdio elicitation_callback parameter
  • External tools become available as Python functions during code execution via MCP elicitation protocol

@@ -0,0 +1,130 @@
"""PydanticAI integration for mcp-run-python tool injection.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the create_tool_elicitation_callback function be moved to pydantic-ai's extensions instead of keeping it in mcp_run_python/ext/?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant