Skip to content

Commit 003cbfe

Browse files
Added mcp 'instructions' attribute to the server (#706)
Added the `instructions` attribute to the MCP servers to solve #704 . Let me know if you want to add an example to the documentation.
1 parent c282324 commit 003cbfe

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/agents/mcp/server.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from mcp.client.sse import sse_client
1313
from mcp.client.streamable_http import GetSessionIdCallback, streamablehttp_client
1414
from mcp.shared.message import SessionMessage
15-
from mcp.types import CallToolResult
15+
from mcp.types import CallToolResult, InitializeResult
1616
from typing_extensions import NotRequired, TypedDict
1717

1818
from ..exceptions import UserError
@@ -73,6 +73,7 @@ def __init__(self, cache_tools_list: bool, client_session_timeout_seconds: float
7373
self.exit_stack: AsyncExitStack = AsyncExitStack()
7474
self._cleanup_lock: asyncio.Lock = asyncio.Lock()
7575
self.cache_tools_list = cache_tools_list
76+
self.server_initialize_result: InitializeResult | None = None
7677

7778
self.client_session_timeout_seconds = client_session_timeout_seconds
7879

@@ -122,7 +123,8 @@ async def connect(self):
122123
else None,
123124
)
124125
)
125-
await session.initialize()
126+
server_result = await session.initialize()
127+
self.server_initialize_result = server_result
126128
self.session = session
127129
except Exception as e:
128130
logger.error(f"Error initializing MCP server: {e}")

0 commit comments

Comments
 (0)