MCP Servers
Deploy Model Context Protocol (MCP) servers that provide tools and context to AI agents and Claude clients.
Overview
MCP Servers are deployable endpoints that expose tools and resources via the Model Context Protocol. They enable AI agents to:
- Query databases and data sources
- Execute file operations
- Call external APIs
- Perform computations
- Access knowledge bases
Quick Start
import { Tenzro } from 'tenzro';const tenzro = new Tenzro({ apiKey: 'your-api-key' });// Deploy an MCP server connected to your databaseconst server = await tenzro.servers.create({projectId: 'project-id',deploymentName: 'my-database-server',aiModel: 'gemini-2.5-flash',dataSourceType: 'data',dataSourceId: 'your-data-db-id', // PostgreSQL databasepublicAccess: false,minInstances: 1,maxInstances: 3,});console.log('Endpoint:', server.full_endpoint);// https://my-database-server.mcp.tenzro.network// List available toolsconst { tools } = await tenzro.servers.getTools(server.deployment_id);console.log(tools);// [{ name: 'query_database', description: '...', inputSchema: {...} }]// Call a tool directlyconst result = await tenzro.servers.callTool(server.deployment_id,'query_database',{ sql: 'SELECT COUNT(*) FROM users' });console.log(result); // { success: true, result: { count: 1234 } }
Data Source Types
MCP servers can connect to different data sources:
| Type | Description | Available Tools |
|---|---|---|
vec | Vector database | search_vectors, insert_vectors, get_stats |
kev | Key-value store | get_value, set_value, list_keys, increment |
data | SQL database | query_database, list_tables, get_schema |
file | Object storage | list_files, get_file_url, upload_file |
graph | Graph database | query_graph, traverse_graph, mutate_graph |
SDK Reference
Create Server
const server = await tenzro.servers.create({projectId: string,deploymentName: string,deploymentDescription?: string,aiModel: AIModel,aiProvider?: 'google',dataSourceType?: 'vec' | 'kev' | 'data' | 'file' | 'graph',dataSourceId?: string,encryptionKeyId?: string, // For encrypted enclavesapiKeys?: string[], // Additional auth keyspublicAccess?: boolean, // Default: falsecorsOrigins?: string[], // Allowed CORS originsmemoryLimitMb?: number, // Default: 512cpuLimit?: number, // Default: 1maxInstances?: number, // Default: 5minInstances?: number, // Default: 1environmentVars?: Record<string, string>,mcpConfig?: Record<string, any>,});
Lifecycle Management
// Start a stopped serverawait tenzro.servers.start(deploymentId);// Stop a running serverawait tenzro.servers.stop(deploymentId);// Update configurationawait tenzro.servers.update(deploymentId, {maxInstances: 10,memoryLimitMb: 1024,});// Delete serverawait tenzro.servers.delete(deploymentId);
Get Tools
const { tools } = await tenzro.servers.getTools(deploymentId);// Tools array contains:interface MCPTool {name: string;description: string;inputSchema: JSONSchema;}
Call Tool
const result = await tenzro.servers.callTool(deploymentId,toolName: string,args: Record<string, any>);// Result:interface ToolResult {success: boolean;result: any;error?: string;}
Events and Logs
const { events } = await tenzro.servers.getEvents(deploymentId, {limit: 100,since: '2024-01-01T00:00:00Z',});// Events include deployment status changes, errors, etc.
Metrics
const { metrics } = await tenzro.servers.getMetrics(deploymentId);// Metrics include:interface ServerMetrics {requestsPerMinute: number;avgLatencyMs: number;errorRate: number;tokensPerMinute: number;currentInstances: number;memoryUsageMb: number;cpuUsagePercent: number;}
Connecting to Agents
Connect MCP servers to agents for tool access:
// Create MCP server for vector searchconst vecServer = await tenzro.servers.create({projectId: 'project-id',deploymentName: 'knowledge-base',aiModel: 'gemini-2.5-flash',dataSourceType: 'vec',dataSourceId: vecDbId,});// Create agent with MCP server accessconst agent = await tenzro.agents.create({projectId: 'project-id',agentName: 'research-assistant',aiModel: 'gemini-2.5-pro',systemPrompt: 'You are a research assistant with access to a knowledge base.',mcpServerIds: [vecServer.deployment_id],});// Agent can now search the vector databaseconst response = await tenzro.agents.chat(agent.agent_id, {message: 'Find information about quantum computing',});
Using with Claude Desktop
Add your MCP server to Claude Desktop's configuration:
{"mcpServers": {"tenzro-database": {"command": "npx","args": ["-y", "@modelcontextprotocol/server-fetch"],"env": {"MCP_SERVER_URL": "https://your-server.mcp.tenzro.network","MCP_API_KEY": "your-api-key"}}}}
Custom MCP Tools
Define custom tools in your server configuration:
const server = await tenzro.servers.create({projectId: 'project-id',deploymentName: 'custom-tools',aiModel: 'gemini-2.5-flash',mcpConfig: {tools: [{name: 'calculate_shipping',description: 'Calculate shipping cost for an order',inputSchema: {type: 'object',properties: {weight: { type: 'number', description: 'Weight in kg' },destination: { type: 'string', description: 'Country code' },},required: ['weight', 'destination'],},handler: `const rates = { US: 10, EU: 15, ASIA: 20 };return { cost: weight * (rates[destination] || 25) };`,},],},});
Security
Access Control
// Restrict access to specific API keysconst server = await tenzro.servers.create({projectId: 'project-id',deploymentName: 'secure-server',publicAccess: false,apiKeys: ['key-1', 'key-2'], // Only these keys can access});// Configure CORS for browser accessawait tenzro.servers.update(deploymentId, {corsOrigins: ['https://your-app.com', 'https://staging.your-app.com'],});
Encrypted Enclaves
// Deploy in a secure enclave with encryptionconst server = await tenzro.servers.create({projectId: 'project-id',deploymentName: 'secure-database-server',dataSourceType: 'data',dataSourceId: dbId,encryptionKeyId: 'your-encryption-key-id', // Uses secure enclave});
Auto-scaling
Servers automatically scale based on load:
const server = await tenzro.servers.create({projectId: 'project-id',deploymentName: 'scalable-server',minInstances: 1, // Always at least 1 instancemaxInstances: 10, // Scale up to 10 under loadmemoryLimitMb: 512, // Per instancecpuLimit: 1, // Per instance});
Best Practices
- Use minimum instances: Set minInstances to 1 for production to avoid cold starts
- Limit data access: Connect servers to specific databases, not entire projects
- Monitor metrics: Track error rates and latency for performance optimization
- Secure access: Disable public access and use API keys for authentication
- Use enclaves: For sensitive data, deploy in encrypted enclaves
Limits
| Resource | Limit |
|---|---|
| Max instances | 20 |
| Max memory per instance | 4 GB |
| Max CPU per instance | 4 cores |
| Request timeout | 5 minutes |
| Max servers per project | 50 |