Skip to main content
Glama
mcp.ts1.35 kB
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { config } from '../config/env.js'; import { registerPrompts } from '../prompts/index.js'; import { registerResources } from '../resources/index.js'; import { registerTools } from '../tools/index.js'; import { buildCapabilities } from './capabilities.js'; export interface ServerOptions { /** Server name (appears in client UI) */ name: string; /** Server version (semver) */ version: string; /** Optional instructions for LLM on how to use this server */ instructions?: string; } /** * Build and configure the MCP server. * * This is the main factory function that: * 1. Creates the McpServer instance with capabilities * 2. Registers all tools, prompts, and resources * 3. Sets up logging */ export function buildServer(options: ServerOptions): McpServer { const { name, version, instructions } = options; const server = new McpServer( { name, version }, { capabilities: buildCapabilities(), instructions: instructions ?? config.INSTRUCTIONS, }, ); // Register all handlers registerTools(server); registerPrompts(server); registerResources(server); // Note: logger.setServer() must be called AFTER server.connect() // to avoid sending MCP notifications before initialization handshake return server; }

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/iceener/files-stdio-mcp-server'

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