Skip to content

feat(mcp): #2228 expose server name on function tools#2789

Closed
IgnazioDS wants to merge 1 commit intoopenai:mainfrom
IgnazioDS:branch/mcp-server-name
Closed

feat(mcp): #2228 expose server name on function tools#2789
IgnazioDS wants to merge 1 commit intoopenai:mainfrom
IgnazioDS:branch/mcp-server-name

Conversation

@IgnazioDS
Copy link
Copy Markdown

Summary

  • add a public mcp_server_name field to FunctionTool
  • populate that field when MCP tools are converted via MCPUtil.to_function_tool()
  • keep the change narrow and typed instead of introducing a general metadata bag
  • add focused tests for MCP population, non-MCP default behavior, and copy/replace preservation

Fixes #2228.

Why

Issue #2228 asks for a reliable way to recover which MCP server a converted function tool came from. The maintainer feedback there suggested a specific field such as mcp_server_name: str | None on FunctionTool rather than a generic metadata dict. This patch follows that direction and preserves backward compatibility by making the new field keyword-only with a default of None.

Validation

  • uv run ruff check src/agents/tool.py src/agents/mcp/util.py tests/mcp/test_mcp_util.py tests/test_function_tool.py
  • PYTHONPATH=src uv run pytest tests/mcp/test_mcp_util.py tests/test_function_tool.py -q
  • uv run mypy src/agents/tool.py src/agents/mcp/util.py --disable-error-code import-not-found --disable-error-code unused-ignore

Notes

The local pytest invocation uses PYTHONPATH=src because this workspace clone is not resolving the local agents package via uv run by default, but the test slice itself passes cleanly.

@github-actions github-actions bot added enhancement New feature or request feature:mcp labels Mar 26, 2026
@seratch seratch changed the title feat(mcp): expose server name on function tools feat(mcp): #2228 expose server name on function tools Mar 26, 2026
@seratch
Copy link
Copy Markdown
Member

seratch commented Mar 26, 2026

Thanks for sharing this. However, we're going to add the property this way: #2654

@seratch seratch closed this Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request feature:mcp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable to access MCP server name via its converted function tool object

2 participants