Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for MCP (Model Context Protocol) Support #49

Open
bigpo opened this issue Dec 28, 2024 · 5 comments
Open

Request for MCP (Model Context Protocol) Support #49

bigpo opened this issue Dec 28, 2024 · 5 comments

Comments

@bigpo
Copy link

bigpo commented Dec 28, 2024

Hello,

I’d like to ask if it would be possible to support the Model Context Protocol (MCP). MCP is an open protocol released by Anthropic, and so far, many third-party MCP server implementations have emerged. Integrating MCP could provide seamless access to this growing ecosystem of tools.

Is there any plan to support MCP in the future? Thank you!

@KennyVaneetvelde
Copy link
Member

@bigpo Thanks for the request!

What is your vision for MCP integration, or what would you say is currently preventing you from creating agents that interface with MCP servers?

Sorry, I am not yet too familiar with MCP as I have not had time yet to look into it closely, so please help me get a clear vision on this!

@bigpo
Copy link
Author

bigpo commented Dec 28, 2024

@KennyVaneetvelde Thank you for your response and interest!

Integrating MCP support into the atomic agents framework would enable seamless interaction with a growing ecosystem of interoperable tools and AI systems. MCP is designed to be lightweight, extensible, and aligns well with the modular nature of atomic agents.

Currently, creating agents that interface with MCP servers requires duplicating integration work for each tool, as the framework lacks built-in support for the protocol. By adopting MCP, atomic agents could simplify this process by providing native compatibility, enabling users to:

  1. Easily register and use MCP tools: MCP supports dynamic tool discovery and execution, which could enhance the agents’ capabilities without manual configuration.
  2. Expand ecosystem participation: Supporting MCP would make atomic agents part of this ecosystem, fostering adoption and community growth.

Adding MCP could be relatively straightforward by aligning it with the current structure for tools in atomic agents. Please consider supporting MCP to enable effortless integration with the expanding ecosystem of MCP-compatible tools and enhance the framework’s interoperability and functionality.

@KennyVaneetvelde
Copy link
Member

Currently, creating agents that interface with MCP servers requires duplicating integration work for each tool, as the framework lacks built-in support for the protocol.
Can you show me a code example of what you mean with this, or what it would look like for a single tool?

Also, as a developer/consumer of the framework, what would your expected usage be? I am interested but I'll need a lot more practical info, not just a generic description of what MCP is and can do

This info is important because if it's mostly just about not wanting to do boilerplate code, it could just be something in the CLI that scaffolds a basic tool with MCP support but I'll have to know exactly what you expect from it..

@bigpo
Copy link
Author

bigpo commented Dec 28, 2024

I believe a concrete example can be drawn from the official documentation: MCP Quickstart - Client. The following code demonstrates how tools can be registered with an MCP server:

async def connect_to_server(self, server_script_path: str):
    """Connect to an MCP server
    
    Args:
        server_script_path: Path to the server script (.py or .js)
    """
    is_python = server_script_path.endswith('.py')
    is_js = server_script_path.endswith('.js')
    if not (is_python or is_js):
        raise ValueError("Server script must be a .py or .js file")
        
    command = "python" if is_python else "node"
    server_params = StdioServerParameters(
        command=command,
        args=[server_script_path],
        env=None
    )
    
    stdio_transport = await self.exit_stack.enter_async_context(stdio_client(server_params))
    self.stdio, self.write = stdio_transport
    self.session = await self.exit_stack.enter_async_context(ClientSession(self.stdio, self.write))
    
    await self.session.initialize()
    
    # List available tools
    response = await self.session.list_tools()
    tools = response.tools
    print("\nConnected to server with tools:", [tool.name for tool in tools])

Additionally, tools can then be utilized as follows:

async def process_query(self, query: str) -> str:
    ...
    response = await self.session.list_tools()
    available_tools = [{ 
        "name": tool.name,
        "description": tool.description,
        "input_schema": tool.inputSchema
    } for tool in response.tools]

    # Initial Claude API call
    response = self.anthropic.messages.create(
        model="claude-3-5-sonnet-20241022",
        max_tokens=1000,
        messages=messages,
        tools=available_tools
    )

I believe the main advantage of supporting MCP is the ability to reuse the extensive toolset within the MCP ecosystem, which can significantly enhance the utility of the framework. However, my perspective may be limited, and there could be additional factors I haven’t fully considered. Please feel free to evaluate this suggestion critically and from multiple angles.

@KennyVaneetvelde
Copy link
Member

Hmm I'll have a look at it and play around with it when I have some time, but in the meanwhile if you can come up with an example that actually uses atomic agents and shows where the problem is, that would be extremely helpful!

Should anyone get to it before I do, I believe a viable first attempt might be to just make a tool with a dynamically constructed output schema

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants