Model Context Protocol (MCP) is the open standard for connecting AI agents to external tools and data sources. Instead of hardcoding tool integrations into every agent, MCP provides a universal protocol -- like USB for AI agents. Any MCP-compatible client can connect to any MCP server, giving agents access to web search, databases, file systems, APIs, and more.
This tutorial walks through setting up MCP tools for AI agents, from understanding the protocol to configuring real tool servers and building a functional agent with web search, file system, and API access.
Key Takeaways
- MCP standardizes how AI agents discover and use tools -- one protocol, any tool
- MCP servers expose tools (functions the agent can call) and resources (data the agent can read)
- Popular MCP servers include web search, filesystem, GitHub, Brave Search, and Puppeteer
- Claude Desktop and other AI clients support MCP out of the box
- SearchHive provides a web search MCP server for agent-powered search
Prerequisites
Before starting, you need:
- Python 3.10+ installed
- Node.js 18+ installed (many MCP servers are JavaScript)
- An AI agent framework or client that supports MCP (Claude Desktop, Cursor, or a custom setup)
- API keys for tools you want to connect (SearchHive, Brave, etc.)
What Is MCP?
MCP (Model Context Protocol) is an open protocol created by Anthropic that standardizes how AI models interact with external tools. It has three components:
- MCP Hosts: AI applications (like Claude Desktop, Cursor, or custom agents) that initiate connections
- MCP Clients: Language-specific libraries that handle the protocol communication
- MCP Servers: Lightweight programs that expose tools, prompts, and resources
Think of it like this: your AI agent is the host, the MCP client library handles the communication, and MCP servers provide the actual capabilities (search, file access, database queries).
Step 1: Understand the MCP Architecture
An MCP server exposes capabilities through three primitives:
- Tools: Functions the agent can invoke (e.g.,
web_search(query),read_file(path)) - Resources: Data sources the agent can read (e.g., files, database records, API responses)
- Prompts: Reusable prompt templates with variables
When an agent needs information, it asks the MCP client to list available tools, then calls the appropriate tool with parameters. The MCP server executes the tool and returns structured results.
Step 2: Set Up Claude Desktop with MCP
The fastest way to start using MCP tools is with Claude Desktop:
- Download and install Claude Desktop
- Open Claude Desktop settings (gear icon > Settings)
- Navigate to the "Developer" section
- Edit the Claude Desktop config file
On macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
On Windows: %APPDATA%\Claude\claude_desktop_config.json
Add MCP servers to the configuration:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed/directory"]
},
"brave-search": {
"command": "npx",
"args": ["-y", "@anthropic-ai/mcp-brave-search"],
"env": {
"BRAVE_API_KEY": "your_brave_api_key_here"
}
}
}
}
Restart Claude Desktop after editing the config. You'll see a hammer icon indicating MCP tools are available.
Step 3: Install and Configure Web Search MCP
For web search in your AI agent, configure a search MCP server. Here are the main options:
Option A: SearchHive MCP Server
SearchHive offers a built-in MCP server for web search:
{
"mcpServers": {
"searchhive": {
"command": "npx",
"args": ["-y", "@searchhive/mcp-server"],
"env": {
"SEARCHHIVE_API_KEY": "your_searchhive_api_key"
}
}
}
}
This exposes SwiftSearch, ScrapeForge, and DeepDive as MCP tools:
swiftsearch: Web search with structured resultsscrapeforge: Extract content from any URLdeepdive: Deep research with multi-page crawling
Option B: Brave Search MCP Server
{
"mcpServers": {
"brave-search": {
"command": "npx",
"args": ["-y", "@anthropic-ai/mcp-brave-search"],
"env": {
"BRAVE_API_KEY": "your_brave_api_key"
}
}
}
}
Brave's MCP server exposes brave_web_search and brave_local_search tools.
Option C: Tavily MCP Server
{
"mcpServers": {
"tavily": {
"command": "npx",
"args": ["-y", "tavily-mcp"],
"env": {
"TAVILY_API_KEY": "your_tavily_api_key"
}
}
}
}
Step 4: Add File System Access
The official filesystem MCP server lets agents read, write, and search files:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/you/projects",
"/Users/you/documents"
]
}
}
}
Security note: Only expose directories you trust the agent to access. The server validates paths against the allowed list.
This exposes tools like:
read_file: Read file contentswrite_file: Write content to fileslist_directory: List directory contentssearch_files: Search files by content pattern
Step 5: Build a Custom MCP Server in Python
For tools not covered by existing MCP servers, build your own:
pip install mcp
# my_tools_server.py
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("my-tools")
@mcp.tool()
def calculate_revenue(prices: list[float], quantities: list[int]) -> dict:
# Calculate total revenue from price and quantity lists
total = sum(p * q for p, q in zip(prices, quantities))
return {"total_revenue": total, "items": len(prices)}
@mcp.tool()
def format_currency(amount: float, currency: str = "USD") -> str:
# Format a number as currency
symbols = {"USD": "$", "EUR": "EUR", "GBP": "GBP"}
symbol = symbols.get(currency, currency)
return f"{symbol}{amount:,.2f}"
@mcp.resource("config://app-settings")
def get_settings() -> str:
# Application settings resource
return "Theme: dark\nLanguage: en\nNotifications: enabled"
if __name__ == "__main__":
mcp.run(transport="stdio")
Add it to your Claude Desktop config:
{
"mcpServers": {
"my-tools": {
"command": "python",
"args": ["/path/to/my_tools_server.py"]
}
}
}
Step 6: Connect Multiple MCP Servers
A single agent can connect to multiple MCP servers simultaneously. Here's a complete configuration with search, filesystem, and custom tools:
{
"mcpServers": {
"searchhive": {
"command": "npx",
"args": ["-y", "@searchhive/mcp-server"],
"env": {
"SEARCHHIVE_API_KEY": "sk-xxx"
}
},
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/home/user/projects"]
},
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "ghp_xxx"
}
},
"my-tools": {
"command": "python",
"args": ["/home/user/my_tools_server.py"]
}
}
}
The agent sees all tools from all servers as a unified tool list. When it decides to search the web, it calls SearchHive. When it needs to read a file, it calls the filesystem server. When it needs to check a GitHub PR, it calls the GitHub server.
Step 7: Use MCP in Custom Python Agents
For programmatic agent setups (not Claude Desktop), use the MCP Python SDK:
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
async def search_with_mcp(query: str):
server_params = StdioServerParameters(
command="npx",
args=["-y", "@searchhive/mcp-server"],
env={"SEARCHHIVE_API_KEY": "your_api_key"}
)
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
# List available tools
tools = await session.list_tools()
print(f"Available tools: {[t.name for t in tools.tools]}")
# Call a tool
result = await session.call_tool(
"swiftsearch",
arguments={"query": query, "limit": 5}
)
return result.content
Step 8: Test Your MCP Setup
After configuring MCP servers, verify everything works:
- Open Claude Desktop and look for the hammer icon (tools available)
- Ask Claude: "What tools do you have available?" -- it should list MCP tools
- Test web search: "Search the web for latest Python 3.13 features"
- Test file access: "List the files in my projects directory"
- Test custom tools: "Calculate revenue for prices [10, 20, 30] and quantities [5, 3, 2]"
If tools don't appear, check the Claude Desktop logs:
- macOS:
~/Library/Logs/Claude/ - Windows:
%APPDATA%\Claude\logs\
Common Issues
MCP server fails to start: Check that npx and node are in your PATH. Run npx -y @modelcontextprotocol/server-filesystem --help in a terminal to verify.
Tools not appearing in Claude Desktop: Restart Claude Desktop after editing the config. Verify free JSON formatter is valid (use a JSON linter).
API key errors: Ensure environment variables in the config match your actual API keys. Don't wrap keys in quotes within the JSON env block.
Permission denied on filesystem: The filesystem MCP server requires explicit directory paths. Use absolute paths and ensure the directories exist.
Timeout on web search: Some MCP servers have default timeouts. Network issues or rate limiting can cause slow responses.
Next Steps
Once MCP tools are working, explore:
- MCP Inspector: Debug tool by Anthropic for testing MCP servers (
npx @anthropic-ai/mcp-inspector) - Community MCP servers: Browse the MCP servers registry for databases, browsers, cloud services, and more
- Custom agents: Build production agents using the MCP Python SDK with frameworks like LangChain or AutoGen
- SearchHive MCP: The SearchHive MCP server gives your agents web search, scraping, and deep research -- get a free API key to get started
Conclusion
MCP is the most important standard for AI agent tooling in 2025. It eliminates vendor lock-in, simplifies agent development, and lets you mix and match tools from any provider. Start with Claude Desktop and a few MCP servers (search, filesystem, GitHub), then build custom servers as your agent needs grow.
Sign up for SearchHive's free tier to get an API key for the SearchHive MCP server. With 500 free credits, you can test web search, scraping, and deep research in your MCP-powered agents today.