Skip to main content
Glama

Demo MCP Server

by kylekanouse
config-resources.tsโ€ข4.5 kB
/** * Configuration Resources * * Example MCP resources that provide configuration and settings information. */ import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js"; import type { MCPModule } from "../types/index.js"; /** * Resource registration function for configuration data */ async function register(server: McpServer): Promise<void> { // Register static configuration resource server.registerResource( "app-config", "config://app", { title: "Application Configuration", description: "Application configuration and settings", mimeType: "application/json" }, async (uri) => { const config = { name: "Demo MCP Server", version: "1.0.0", environment: process.env.NODE_ENV || "development", features: { tools: true, resources: true, prompts: true, logging: true }, limits: { maxRequestSize: "10MB", requestTimeout: "30s", maxConcurrentRequests: 100 }, created: new Date().toISOString() }; return { contents: [ { uri: uri.href, mimeType: "application/json", text: JSON.stringify(config, null, 2) } ] }; } ); // Register dynamic settings resource template server.registerResource( "setting", new ResourceTemplate("settings://{category}/{key}", { list: undefined }), { title: "Configuration Setting", description: "Access specific configuration settings by category and key" }, async (uri, { category, key }) => { // Mock configuration data - in a real app this would come from a config store const mockSettings: Record<string, Record<string, any>> = { server: { port: 3000, host: "localhost", ssl: false, maxConnections: 1000 }, database: { host: "localhost", port: 5432, name: "mcp_demo", ssl: true }, logging: { level: "info", format: "json", destination: "console" }, features: { analytics: true, monitoring: true, debugging: false } }; const categorySettings = mockSettings[category as string]; if (!categorySettings) { return { contents: [ { uri: uri.href, mimeType: "text/plain", text: `Configuration category '${category}' not found` } ] }; } const value = categorySettings[key as string]; if (value === undefined) { return { contents: [ { uri: uri.href, mimeType: "text/plain", text: `Setting '${key}' not found in category '${category}'` } ] }; } return { contents: [ { uri: uri.href, mimeType: "application/json", text: JSON.stringify({ category, key, value, type: typeof value, timestamp: new Date().toISOString() }, null, 2) } ] }; } ); // Register health check resource server.registerResource( "health", "health://status", { title: "Health Status", description: "System health and status information", mimeType: "application/json" }, async (uri) => { const health = { status: "healthy", timestamp: new Date().toISOString(), uptime: process.uptime(), memory: process.memoryUsage(), version: process.version, checks: { server: "ok", memory: process.memoryUsage().heapUsed < 500 * 1024 * 1024 ? "ok" : "warning", uptime: process.uptime() > 0 ? "ok" : "error" } }; return { contents: [ { uri: uri.href, mimeType: "application/json", text: JSON.stringify(health, null, 2) } ] }; } ); } /** * Export the MCP module */ export const configResources: MCPModule = { register, metadata: { name: "config-resources", description: "Configuration and settings resources for MCP", version: "1.0.0", author: "PCN" } }; export default configResources;

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/kylekanouse/Test-MCP---DEMO-MCP-Dev-1'

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