Skip to main content
Glama
TedTschopp

MCP Server on Cloudflare Workers & Azure Functions

by TedTschopp
resources.ts4.01 kB
/** * Resource Management Module * * This module defines all available resources and provides helper functions * for resource management. Resources provide contextual information to AI * applications through the MCP protocol. */ /** * Resource definition structure */ export interface ResourceDefinition { uri: string; name: string; description: string; mimeType: string; } /** * All available static resources * * In a production environment, you might want to: * - Load these from a configuration file * - Generate them dynamically based on server state * - Fetch them from a database or external service */ export const RESOURCES: ResourceDefinition[] = [ { uri: 'config://server/info', name: 'Server Information', description: 'Information about this MCP server', mimeType: 'application/json', }, { uri: 'config://server/status', name: 'Server Status', description: 'Current status and metrics of the server', mimeType: 'application/json', }, { uri: 'docs://mcp/getting-started', name: 'MCP Getting Started Guide', description: 'Guide for using this MCP server', mimeType: 'text/markdown', }, ]; /** * Generate content for a specific resource * * @param uri - The URI of the resource to generate content for * @returns Resource content as a string * @throws Error if the URI is not recognized */ export function generateResourceContent(uri: string): string { switch (uri) { case 'config://server/info': return JSON.stringify({ name: 'cloudflare-mcp-server', version: '1.0.0', description: 'MCP server running on Cloudflare Workers', capabilities: ['tools', 'prompts', 'resources', 'logging'], endpoints: { health: '/health', mcp: '/mcp', }, }, null, 2); case 'config://server/status': return JSON.stringify({ status: 'operational', uptime: typeof process !== 'undefined' && process.uptime ? Math.floor(process.uptime()) : 'N/A', timestamp: new Date().toISOString(), memory: typeof process !== 'undefined' && process.memoryUsage ? process.memoryUsage() : 'N/A', }, null, 2); case 'docs://mcp/getting-started': return `# Getting Started with Cloudflare MCP Server ## Available Tools - **get_time**: Returns the current server time - **echo**: Echoes back a message - **add**: Adds two numbers together ## Available Prompts - **code_review**: Get code review assistance - **explain_concept**: Get explanations of technical concepts - **debug_helper**: Get debugging assistance - **api_design**: Get API design guidance - **refactor_suggestion**: Get code refactoring suggestions ## Available Resources - **config://server/info**: Server information and metadata - **config://server/status**: Current server status and metrics - **docs://mcp/getting-started**: This getting started guide ## Usage Connect your MCP client to this server to access tools, prompts, and resources. ### Local Testing (stdio) \`\`\`bash npm run dev \`\`\` ### Cloudflare Workers (HTTP) Deploy to Cloudflare Workers and access via HTTP endpoints: - Health check: GET /health - MCP protocol: POST /mcp For more information, see the README.md file. `; default: throw new Error(`Unknown resource URI: ${uri}`); } } /** * Resource template definition */ export interface ResourceTemplate { uriTemplate: string; name: string; description: string; mimeType: string; } /** * All available resource templates * * Resource templates use URI template syntax (RFC 6570) to define * parameterized resources. Clients can fill in the parameters to * access dynamic resources. */ export const RESOURCE_TEMPLATES: ResourceTemplate[] = [ { uriTemplate: 'log://{level}/{message}', name: 'Log Entry', description: 'Create a log entry with specified level and message', mimeType: 'text/plain', }, ];

Latest Blog Posts

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/TedTschopp/MCP-Server-on-CloudFlare'

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