Neuron AI
GitHubForumNewsletter
  • Getting Started
    • Introduction
  • Key Concepts
  • Installation
  • Agent
  • Tools & Function Calls
  • Streaming
  • RAG
  • Attach Images
  • Advanced
    • Structured Output
    • Logging & Observability
    • MCP Servers Connection
    • Error Handling
  • Components
    • AI provider
    • Chat History & Memory
    • Embeddings Provider
    • Vector Store
    • Data loader
  • Post Processor
  • Examples
    • YouTube Agent
Powered by GitBook
On this page
  1. Advanced

MCP Servers Connection

Connect your agent with Tools provided by MCP (Model Context Protocol) servers.

PreviousLogging & ObservabilityNextError Handling

Last updated 29 days ago

MCP is an open source standard designed by Anthropic, to connect your agents to data sources, such as your application database or external APIs.

Thanks to this protocol you can make tools exposed by an external server available to your agent.

Companies can build servers to allow developers to connect Agents to their platforms. Here are a couple of directories with available MCP servers:

  • MCP official GitHub -

  • MCP-GET registry -

Once you have one or more MCP server on your machine, you can make their resousìrces available to your agent.

use NeuronAI\Agent;
use NeuronAI\Providers\Anthropic\Anthropic;
use NeuronAI\MCP\McpConnector;

class MyAgent extends Agent 
{
    protected function provider()
    {
        return new Anthropic(...);
    }
    
    public function instructions(): string
    {
        return new SystemPrompt(["<SYSTEM PROMPT>"]);
    }
    
    protected function tools()
    {
        return [
            ...McpConnector::make([
                'command' => 'npx',
                'args' => ['-y', '@modelcontextprotocol/server-everything'],
            ])->tools(),
            
            
            ...McpConnector::make([
                // ... another MCP server configuration
            ])->tools(),
        ];
    }
}

You should create an McpConnector instance for each MCP server you want to interact to.

Neuron automatically discovers the tools exposed by the server and connects them to your agent.

When the agent decides to run a tool, Neuron will generate the appropriate request to call the tool on the MCP servers and return the result to the LLM to continue the task. It feels exactly like with your own defined tools, but you can access a huge archive of predefined actions your agent can perform with just one line of code.

You can check the agent running every step using the Inspector monitoring dashboard:

Learn more about observability in the section.

https://github.com/modelcontextprotocol/servers
https://mcp-get.com/
Observability