Skip to content
This repository was archived by the owner on Jan 30, 2026. It is now read-only.

feat: added tool Injection via MCP Elicitation#19

Open
yamanahlawat wants to merge 2 commits intopydantic:mainfrom
yamanahlawat:features/main
Open

feat: added tool Injection via MCP Elicitation#19
yamanahlawat wants to merge 2 commits intopydantic:mainfrom
yamanahlawat:features/main

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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant