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 database
const 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 database
publicAccess: false,
minInstances: 1,
maxInstances: 3,
});
console.log('Endpoint:', server.full_endpoint);
// https://my-database-server.mcp.tenzro.network
// List available tools
const { tools } = await tenzro.servers.getTools(server.deployment_id);
console.log(tools);
// [{ name: 'query_database', description: '...', inputSchema: {...} }]
// Call a tool directly
const 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:

TypeDescriptionAvailable Tools
vecVector databasesearch_vectors, insert_vectors, get_stats
kevKey-value storeget_value, set_value, list_keys, increment
dataSQL databasequery_database, list_tables, get_schema
fileObject storagelist_files, get_file_url, upload_file
graphGraph databasequery_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 enclaves
apiKeys?: string[], // Additional auth keys
publicAccess?: boolean, // Default: false
corsOrigins?: string[], // Allowed CORS origins
memoryLimitMb?: number, // Default: 512
cpuLimit?: number, // Default: 1
maxInstances?: number, // Default: 5
minInstances?: number, // Default: 1
environmentVars?: Record<string, string>,
mcpConfig?: Record<string, any>,
});

Lifecycle Management

// Start a stopped server
await tenzro.servers.start(deploymentId);
// Stop a running server
await tenzro.servers.stop(deploymentId);
// Update configuration
await tenzro.servers.update(deploymentId, {
maxInstances: 10,
memoryLimitMb: 1024,
});
// Delete server
await 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 search
const 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 access
const 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 database
const 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 keys
const 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 access
await tenzro.servers.update(deploymentId, {
corsOrigins: ['https://your-app.com', 'https://staging.your-app.com'],
});

Encrypted Enclaves

// Deploy in a secure enclave with encryption
const 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 instance
maxInstances: 10, // Scale up to 10 under load
memoryLimitMb: 512, // Per instance
cpuLimit: 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

ResourceLimit
Max instances20
Max memory per instance4 GB
Max CPU per instance4 cores
Request timeout5 minutes
Max servers per project50