Skip to content

Feature Request: Support for accessing instructions from InitializeResultΒ #405

@Mrhy1996

Description

@Mrhy1996

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

In tools.py at line 481:

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:

  1. Providing context to LLM agents about how to use the MCP server effectively
  2. Displaying server-specific instructions to users
  3. Programmatically accessing server metadata and capabilities
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions