AI Agent Integration Guide: Connecting Claude, ChatGPT, and Custom Agents

AI Agent Integration Guide
Integrating AI agents with your MCP servers unlocks powerful capabilities. This guide shows you how to connect popular AI agents and build custom integrations.
Supported AI Agents
MCP Bundler supports all major AI platforms:
- Claude (Anthropic)
- ChatGPT (OpenAI)
- Gemini (Google)
- Custom Agents (Built with LangChain, AutoGPT, etc.)
Integrating with Claude
Claude Desktop and Claude Code both support MCP natively. Here's how to connect:
1. Configure Claude Desktop
Add your MCP server to Claude's configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"my-server": {
"command": "node",
"args": ["/path/to/server/index.js"],
"env": {
"DATABASE_URL": "postgresql://..."
}
}
}
}2. Test the Connection
Start Claude Desktop and verify your MCP server appears in the integrations panel. You should see your server's tools and resources listed.
3. Use MCP Tools in Conversations
User: Query the user database for active users
Claude: I'll use the query_users tool to fetch active users.
[Uses MCP tool: query_users with filter: "active=true"]
Here are the 15 active users:
1. John Doe (john@example.com)
2. Jane Smith (jane@example.com)
...Integrating with ChatGPT
ChatGPT can connect to MCP servers via OpenAI's Plugin system or custom GPTs.
Option 1: OpenAI Plugin
Create a plugin manifest:
{
"schema_version": "v1",
"name_for_human": "MCP Database",
"name_for_model": "mcp_database",
"description_for_human": "Access database via MCP",
"description_for_model": "Query and update database records using MCP protocol",
"auth": {
"type": "service_http",
"authorization_type": "bearer"
},
"api": {
"type": "openapi",
"url": "https://your-server.com/openapi.json"
}
}Option 2: Custom GPT
- Go to ChatGPT > Explore GPTs > Create a GPT
- Configure actions using your MCP server's OpenAPI spec
- Add authentication (API key)
- Test with sample queries
Building Custom AI Agent Integrations
Using LangChain
from langchain.agents import initialize_agent, Tool
from langchain.llms import OpenAI
import requests
def query_mcp_server(query: str) -> str:
"""Query MCP server"""
response = requests.post(
"https://your-server.com/mcp/tools/call",
json={
"name": "query_users",
"arguments": {"filter": query}
},
headers={"Authorization": f"Bearer {API_KEY}"}
)
return response.json()["content"][0]["text"]
tools = [
Tool(
name="QueryDatabase",
func=query_mcp_server,
description="Query user database with filters"
)
]
agent = initialize_agent(
tools,
OpenAI(temperature=0),
agent="zero-shot-react-description"
)
result = agent.run("Find all active users")Using AutoGPT
from autogpt.agent import Agent
from autogpt.config import Config
from autogpt.memory import get_memory
config = Config()
agent = Agent(
ai_name="DatabaseAgent",
memory=get_memory(config),
full_message_history=[],
next_action_count=0,
)
# Add MCP tool
agent.add_tool({
"name": "query_database",
"description": "Query the MCP database",
"parameters": {
"query": {"type": "string", "description": "SQL query"}
},
"handler": lambda query: query_mcp_server(query)
})Authentication Strategies
API Key Authentication
const client = new MCPClient({
endpoint: "https://your-server.com",
auth: {
type: "bearer",
token: process.env.MCP_API_KEY,
},
});OAuth 2.0
const client = new MCPClient({
endpoint: "https://your-server.com",
auth: {
type: "oauth2",
clientId: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
tokenUrl: "https://auth.example.com/token",
},
});mTLS (Mutual TLS)
For high-security environments:
const client = new MCPClient({
endpoint: "https://your-server.com",
auth: {
type: "mtls",
cert: fs.readFileSync("client-cert.pem"),
key: fs.readFileSync("client-key.pem"),
ca: fs.readFileSync("ca-cert.pem"),
},
});Error Handling
Retry Logic
async function callMCPWithRetry(
tool: string,
args: any,
maxRetries: number = 3
): Promise<any> {
for (let i = 0; i < maxRetries; i++) {
try {
return await client.callTool(tool, args);
} catch (error) {
if (i === maxRetries - 1) throw error;
await new Promise(resolve => setTimeout(resolve, 1000 * (i + 1)));
}
}
}Graceful Degradation
async function queryWithFallback(query: string) {
try {
return await client.callTool("query_database", { query });
} catch (error) {
logger.warn("MCP unavailable, using cache", { error });
return await getFromCache(query);
}
}Performance Optimization
Connection Pooling
const pool = new MCPConnectionPool({
min: 5,
max: 20,
idleTimeoutMillis: 30000,
});
const client = await pool.acquire();
try {
const result = await client.callTool("query_users", { limit: 100 });
return result;
} finally {
pool.release(client);
}Request Batching
const batch = client.batch();
batch.callTool("get_user", { id: 1 });
batch.callTool("get_user", { id: 2 });
batch.callTool("get_user", { id: 3 });
const results = await batch.execute();Monitoring Integration Health
Health Checks
setInterval(async () => {
try {
await client.ping();
metrics.record("mcp.health", 1);
} catch (error) {
metrics.record("mcp.health", 0);
logger.error("MCP health check failed", { error });
}
}, 60000); // Every minuteUsage Metrics
Track important metrics:
const metrics = {
totalRequests: 0,
successfulRequests: 0,
failedRequests: 0,
averageLatency: 0,
};
async function trackRequest<T>(fn: () => Promise<T>): Promise<T> {
const start = Date.now();
metrics.totalRequests++;
try {
const result = await fn();
metrics.successfulRequests++;
return result;
} catch (error) {
metrics.failedRequests++;
throw error;
} finally {
const duration = Date.now() - start;
metrics.averageLatency =
(metrics.averageLatency * (metrics.totalRequests - 1) + duration) /
metrics.totalRequests;
}
}Best Practices
- Always implement timeouts - Prevent hanging requests
- Use connection pooling - Reuse connections for better performance
- Implement retry logic - Handle transient failures gracefully
- Monitor integration health - Track success rates and latency
- Secure credentials - Never hardcode API keys
- Rate limit requests - Respect MCP server limits
- Cache when possible - Reduce unnecessary API calls
Conclusion
Integrating AI agents with MCP servers opens up endless possibilities. Whether you're using Claude, ChatGPT, or building custom agents, the MCP protocol provides a standardized way to connect AI to your data and tools.
Ready to start integrating? Check out MCP Bundler to find pre-built MCP servers for your use case.
Next Steps
New Privacy, Security, and About pages
We published EU-focused Privacy and Security pages, and gave the About page real content for the first time.
How to Build Production-Ready MCP Servers
Complete guide to building, deploying, and scaling MCP servers for AI agents. Learn best practices, architecture patterns, and optimization techniques.