Connect to external tools with MCP
MCP (Model Context Protocol) is a standard for connecting AI agents to external tools and data sources. Use MCP to extend your agents with capabilities like web research, database access, API integrations, and more.
What is MCP?
MCP provides a standardized way for agents to discover and use external tools. MCP servers expose tools that agents can call, with proper schema definitions and execution handling.
Note: MCP integration is available in the TypeScript SDK. Support for other languages is coming soon.
Using MCP Servers
Configure MCP servers to give agents access to external tools.
TypeScript
import { Agent, MCPServerConfig } from '@autohandai/agent-sdk';
const agent = new Agent({
name: "Researcher",
instructions: "Research topics using web search and external APIs.",
mcpServers: [
{
name: "brave-search",
command: "npx",
args: ["-y", "@modelcontextprotocol/server-brave-search"],
},
{
name: "filesystem",
command: "npx",
args: ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/directory"],
},
],
});
Python
# MCP support coming soon to Python SDK
Java
// MCP support coming soon to Java SDK
Go
// MCP support coming soon to Go SDK
Swift
// MCP support coming soon to Swift SDK
Rust
// MCP support coming soon to Rust SDKPopular MCP Servers
There are many community-maintained MCP servers available:
- Brave Search: Web search capabilities
- Filesystem: Access to local and remote filesystems
- GitHub: Repository operations and code search
- PostgreSQL: Database query and management
- Slack: Messaging and notifications
- Puppeteer: Web automation and scraping
- Memory: Persistent memory and state management
Learn more: See the MCP documentation for a complete list of available servers and how to use them.
Custom MCP Servers
You can build your own MCP servers to expose custom tools to agents.
TypeScript
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
const server = new Server(
{
name: "my-custom-server",
version: "1.0.0",
},
{
capabilities: {
tools: {},
},
}
);
// Define a custom tool
server.setRequestHandler(ListToolsRequestSchema, async () => {
return {
tools: [
{
name: "my_custom_tool",
description: "Description of what this tool does",
inputSchema: {
type: "object",
properties: {
param1: {
type: "string",
description: "Parameter description",
},
},
required: ["param1"],
},
},
],
};
});
// Handle tool execution
server.setRequestHandler(CallToolRequestSchema, async (request) => {
const { name, arguments: args } = request.params;
if (name === "my_custom_tool") {
// Execute your custom logic
return {
content: [
{
type: "text",
text: `Tool executed with param1: ${args.param1}`,
},
],
};
}
throw new Error(`Unknown tool: ${name}`);
});
async function main() {
const transport = new StdioServerTransport();
await server.connect(transport);
}
main().catch(console.error);
Python
# MCP server creation coming soon
Java
// MCP server creation coming soon
Go
// MCP server creation coming soon
Swift
// MCP server creation coming soon
Rust
// MCP server creation coming soonUse Cases
- Web Research: Use Brave Search MCP to gather information from the web
- Database Access: Query databases directly with PostgreSQL MCP
- API Integration: Connect to external APIs through custom MCP servers
- File Operations: Access remote filesystems with Filesystem MCP
- Notifications: Send Slack messages or emails via MCP
- Web Automation: Scrape websites with Puppeteer MCP
Best Practices
- Validate tool outputs: Always validate MCP tool results before using them
- Handle errors gracefully: MCP servers may be unavailable or return errors
- Use appropriate permissions: Configure permissions for MCP tools that modify state
- Monitor usage: Track which MCP tools are being used and how frequently
- Secure credentials: Store API keys and credentials securely, not in code