You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python: [Bug]: Support MCP tool binding by reference in declarative YAML #4927
There is no way to reference an MCP connection by identifier - connection details must be redeclared in every agent and workflow that uses the same MCP server, coupling sensitive infrastructure config to business workflow files.
The expected model is that MCP connections are declared once in configuration or code, and workflow YAML references them by name, declaring only which tools each agent is allowed to use.
Current Behaviour
Passing a pre-built MCP tool via bindings is ignored. MAF constructs the tool directly from the YAML spec regardless. Results in server_url: '' being sent to the API, returning a 500.
Note: McpTool does accept a bindings field (inherited from Tool) but _parse_tool in AgentFactory never reads it for the MCP case, unlike FunctionTool where bindings correctly resolve the callable.
The only working workaround is passing the tool at agent.run() with no tools block in the YAML, but this loses per-agent tool scoping entirely.
Code Sample
# Minimal agent YAML — no url, no headers, no connection details.# Just the name and the allowed tools.
AGENT_YAML = """
kind: Prompt
name: TestAgent
instructions: You are a helpful assistant.
model:
id: gpt-4.1
provider: AzureOpenAI.Responses
tools:
- kind: mcp
name: product-mcp
allowedTools:
- customer_search
# connection resolved from bindings by name at runtime
"""
async def main():
mcp_tool = OpenAIResponsesClient.get_mcp_tool(
name="product-mcp",
description="Product MCP server",
url="http://example.com",
headers={"X-API-Key": "..."},
approval_mode="never_require",
allowed_tools=["customer_search"],
)
factory = AgentFactory( safe_mode=False, bindings={"product-mcp": mcp_tool},)async with factory.create_agent_from_yaml(AGENT_YAML) as agent: response = await agent.run("Search for customer Inforshow") print(f"Response: {response.text}")
From our understanding, Azure Foundry solves this cleanly via project_connection_id: MCP connections are registered centrally in the project (including headers and secrets) and referenced by name in the YAML:
Inês G Gonçalves (@IGGoncalves) I believe you are referring to declarative agents? because declarative workflows InvokeMcpTool does support custom headers. As for declarative agents, please see the closing comment on #4582. An issue was filed on Agent schema to support custom headers there.
Description
MAF declarative workflows require embedding full MCP connection details directly in the YAML tool definition. Two problems make this unworkable:
urlis available. (Tracked in Python: [Bug]: Support custom HTTP headers in declarative YAML MCP tool definitions #4582)The expected model is that MCP connections are declared once in configuration or code, and workflow YAML references them by name, declaring only which tools each agent is allowed to use.
Current Behaviour
Passing a pre-built MCP tool via
bindingsis ignored. MAF constructs the tool directly from the YAML spec regardless. Results inserver_url: ''being sent to the API, returning a 500.The only working workaround is passing the tool at
agent.run()with notoolsblock in the YAML, but this loses per-agent tool scoping entirely.Code Sample
Error Messages / Stack Traces
Package Versions
agent-framework: 1.0.0rc4, agent-framework-declarative: 1.0.0b260311
Python Version
3.13
Additional Context
From our understanding, Azure Foundry solves this cleanly via
project_connection_id: MCP connections are registered centrally in the project (including headers and secrets) and referenced by name in the YAML:Could a similar behavior be achievable through MAF, with centralized code definitions?