-
Notifications
You must be signed in to change notification settings - Fork 373
Description
Feature Request: Support for accessing instructions from InitializeResult
Metadata-Version: 2.4
Name: langchain-mcp-adapters
Version: 0.2.1
TL;DR
Problem: MCP servers return valuable instructions in their InitializeResult, but langchain-mcp-adapters discards this data at line 481 of tools.py.
Solution: Create a new instructions.py module with functions like get_instructions() to access this important metadata.
Impact: Zero breaking changes, follows existing package patterns, enables better MCP server integration.
Description
According to the MCP protocol specification, the initialize() method returns an InitializeResult that includes an instructions field in the ServerCapabilities. However, in the current implementation of langchain-mcp-adapters, this result is discarded after calling await tool_session.initialize().
Current Behavior
async with create_session(
connection, mcp_callbacks=mcp_callbacks
) as tool_session:
await tool_session.initialize() # β Result is discarded here
tools = await _list_all_tools(tool_session)The InitializeResult returned by initialize() contains valuable information including the instructions field which provides server-specific guidance for AI models, but it's currently being thrown away.
Expected Behavior
It would be beneficial to have a way to access the instructions field from the InitializeResult. This could be useful for:
- Providing context to LLM agents about how to use the MCP server effectively
- Displaying server-specific instructions to users
- Programmatically accessing server metadata and capabilities
- Following the MCP protocol specification properly
Proposed Solution
I suggest creating a new module file instructions.py in the langchain_mcp_adapters package to handle server capabilities, including the instructions field.
Thank you for maintaining this excellent library! This feature would greatly enhance the usability of MCP servers with LangChain applications.