Integrating flAPI with Claude
Claude from Anthropic supports the Model Context Protocol (MCP), making it easy to give Claude access to your flAPI endpoints as tools.
Quick Start
1. Configure MCP in Claude Desktop
Edit Claude's configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"flapi-production": {
"command": "node",
"args": ["/path/to/flapi-mcp-adapter.js"],
"env": {
"FLAPI_URL": "http://localhost:8080",
"FLAPI_API_KEY": "your-api-key"
}
}
}
}
2. Create MCP Adapter
// flapi-mcp-adapter.js
const axios = require('axios');
const FLAPI_URL = process.env.FLAPI_URL || 'http://localhost:8080';
const API_KEY = process.env.FLAPI_API_KEY;
async function listTools() {
const response = await axios.get(`${FLAPI_URL}/mcp/tools`, {
headers: { 'Authorization': `Bearer ${API_KEY}` }
});
return response.data;
}
async function callTool(name, params) {
const response = await axios.post(`${FLAPI_URL}/mcp/call`, {
tool: name,
parameters: params
}, {
headers: { 'Authorization': `Bearer ${API_KEY}` }
});
return response.data;
}
// MCP protocol implementation
// (Full implementation available in examples repo)
3. Restart Claude Desktop
Close and reopen Claude Desktop. Your flAPI tools will now appear!
Example Usage
Once configured, you can chat with Claude naturally:
You: "What are our top-performing marketing campaigns in the US?"
Claude: Let me check that for you.
[Calls get_campaign_performance tool with country="US"]
Claude: Based on the data, here are your top campaigns in the US:
1. Summer Sale 2024: $45K revenue, 150K clicks
2. Back to School: $38K revenue, 120K clicks
...
More Information
For detailed examples and the full MCP adapter code, see:
- MCP Overview: Complete Model Context Protocol guide
- Endpoints Overview: Configure API endpoints
- YAML Syntax: MCP tool descriptions
- Examples Repository: Full code examples
Next Steps
- MCP Overview: Deep dive into MCP integration
- SQL Templating: Create data access patterns
- Authentication: Secure AI agent access
- Examples: See MCP tools in action
Need help setting up Claude integration? Contact our team.