Creating MCP Agents
Want to give your AI Agent more powerful capabilities? MCP (Model Context Protocol) is a standard protocol for connecting external resources. Through MCP, your AI can access file systems, databases, APIs, and various external resources, becoming a feature-rich intelligent assistant.
Basic Structure#
MCP agents provide two connection methods:
- Using Local Commands - Start local MCP services:
type: mcp
command: npx
args: ["-y", "@modelcontextprotocol/server-filesystem", "."]
When using local commands:
type
: Must be set tomcp
, specifying this is an MCP agentcommand
: Base command to run the MCP serverargs
: Array of arguments passed to the command- First element is usually the package name implementing the MCP server
- Additional parameters can be passed based on specific MCP server requirements
- Using URL to Connect to Remote Servers:
type: mcp
url: "http://localhost:3000"
When connecting to remote servers:
type
: Must be set tomcp
, identifying this as an MCP agenturl
: URL of the remote MCP server to connect to, can be local or remote
How It Works#
MCP agents act as a bridge between AI and the external world, helping AI access various external resources. MCP servers can provide:
- Tools: Executable functions that can be called by AI, extending AI's operational capabilities
- Resources: Data sources accessible by AI, providing rich information
- Resource Templates: Patterns for dynamically generating resources, supporting flexible resource access
When an MCP agent initializes, the AIGNE framework performs the following steps:
- Start the MCP server using the provided command and arguments
- Connect to the server and discover available tools and resources
- Make these tools and resources available to AI through standardized interfaces
Popular MCP Servers#
Here are some commonly used MCP server examples:
- File System Server - Provides file operation capabilities:
type: mcp
command: npx
args: ["-y", "@modelcontextprotocol/server-filesystem", "."]
- SQLite Database Server - Provides database operation capabilities:
type: mcp
command: npx
args: ["-y", "@modelcontextprotocol/server-sqlite", "database.db"]
- GitHub Server - Provides GitHub repository access capabilities:
type: mcp
command: npx
args: ["-y", "@modelcontextprotocol/server-github"]
Now you understand how to create MCP agents. Through MCP agents, your AI has:
- File system access and operation capabilities
- Database query and management functions
- Various external API connection capabilities
- Collaboration capabilities with standard MCP servers
Next Step: Choose the appropriate MCP server according to your needs to expand AI's functional scope.
Reference: MCP Official Documentation