Skip to main content
Glama

AI Agent Template MCP Server

by bswa006
anthropic-integration.ts1.93 kB
/** * Example: Anthropic/Claude Integration * Shows how to integrate MCP with Claude in one line */ import Anthropic from '@anthropic-ai/sdk'; import { MCPAnthropic } from '../src/agents/mcp-anthropic'; // Initialize MCP for Anthropic const mcp = new MCPAnthropic({ apiKey: process.env.MCP_API_KEY, validateBefore: true, // Validate before sending to Claude correctAfter: true, // Auto-correct Claude's output streamValidation: true, // Real-time validation for streaming minScore: 85, // Minimum quality score }); // Initialize Anthropic client const anthropic = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY, }); // ✨ One-line integration const enhancedAnthropic = mcp.enhance(anthropic); // Now use Claude as normal - MCP automatically validates! async function generateComponent() { const response = await enhancedAnthropic.messages.create({ model: 'claude-3-opus-20240229', max_tokens: 1000, messages: [{ role: 'user', content: 'Create a React component for a user profile card with TypeScript' }] }); console.log(response.content); // Output will be automatically validated and corrected! } // Example with streaming async function streamComponent() { const stream = await enhancedAnthropic.messages.create({ model: 'claude-3-opus-20240229', max_tokens: 1000, stream: true, messages: [{ role: 'user', content: 'Create a complex dashboard component with charts' }] }); // MCP validates in real-time as Claude generates for await (const chunk of stream) { process.stdout.write(chunk.choices[0]?.delta?.content || ''); } } // Get validation statistics async function getStats() { const stats = await mcp.getStats(); console.log('Validation Statistics:', stats); } // Configure on the fly mcp.configure({ minScore: 90, // Increase quality threshold injectBestPractices: true, });

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bswa006/mcp-context-manager'

If you have feedback or need assistance with the MCP directory API, please join our Discord server