Skip to main content
Glama

Demo MCP Server

by kylekanouse
system-info-resources.tsโ€ข3.4 kB
/** * System Information Resources * * Example MCP resources that provide system and environment information. */ import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js"; import type { MCPModule } from "../types/index.js"; import { hostname, platform, arch, cpus, totalmem, freemem } from "os"; /** * Resource registration function for system information */ async function register(server: McpServer): Promise<void> { // Register static system info resource server.registerResource( "system-info", "system://info", { title: "System Information", description: "Basic system and environment information", mimeType: "application/json" }, async (uri) => { const systemInfo = { hostname: hostname(), platform: platform(), architecture: arch(), nodeVersion: process.version, cpuCount: cpus().length, totalMemory: Math.round(totalmem() / 1024 / 1024 / 1024) + " GB", freeMemory: Math.round(freemem() / 1024 / 1024 / 1024) + " GB", uptime: Math.round(process.uptime()) + " seconds", timestamp: new Date().toISOString() }; return { contents: [ { uri: uri.href, mimeType: "application/json", text: JSON.stringify(systemInfo, null, 2) } ] }; } ); // Register dynamic environment variable resource server.registerResource( "env-var", new ResourceTemplate("env://{varName}", { list: undefined }), { title: "Environment Variable", description: "Access environment variables by name" }, async (uri, { varName }) => { const value = process.env[varName as string]; if (value === undefined) { return { contents: [ { uri: uri.href, mimeType: "text/plain", text: `Environment variable '${varName}' is not set` } ] }; } return { contents: [ { uri: uri.href, mimeType: "text/plain", text: value } ] }; } ); // Register process information resource server.registerResource( "process-info", "process://info", { title: "Process Information", description: "Current Node.js process information", mimeType: "application/json" }, async (uri) => { const processInfo = { pid: process.pid, ppid: process.ppid, platform: process.platform, arch: process.arch, nodeVersion: process.version, execPath: process.execPath, argv: process.argv, cwd: process.cwd(), memoryUsage: process.memoryUsage(), uptime: process.uptime(), timestamp: new Date().toISOString() }; return { contents: [ { uri: uri.href, mimeType: "application/json", text: JSON.stringify(processInfo, null, 2) } ] }; } ); } /** * Export the MCP module */ export const systemInfoResources: MCPModule = { register, metadata: { name: "system-info-resources", description: "System and environment information resources for MCP", version: "1.0.0", author: "PCN" } }; export default systemInfoResources;

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