createMcpServer

The entry point for defining any mcponce server.

TYPESCRIPT
import { createMcpServer } from 'mcponce';

const app = createMcpServer(options);

Signatures #

TYPESCRIPT
function createMcpServer<TContext = unknown>(
  config: McpServerConfig<TContext> | string
): McpApp<TContext>;

If a string is provided, it is treated as { name: config }:

TYPESCRIPT
const app = createMcpServer('my-server');

Configuration Options (McpServerConfig) #

PropertyTypeDefaultDescription
namestringRequiredThe unique identifier for this MCP server.
versionstring'1.0.0'Semantic version reported to clients during handshake.
hoststring'127.0.0.1'Host interface to bind when running HTTP.
portnumberundefinedPort number for Streamable HTTP server.
dataDirstring'~/.mcponce'Directory for lockfiles, logs, and registry state.
loggingLoggingConfigundefinedLog rotation and retention settings.
loggerLoggerundefinedCustom logger adapter (e.g. Pino, Winston).
context() => TContextundefinedAsync or sync factory creating the shared context.
toolTimeoutMsnumber60000 (1m)Global timeout in ms for tool execution (0 disables).
sequentialbooleanfalseIf true, processes all tools on this server sequentially.
maxConcurrencynumberundefinedUpper limit of simultaneous tool executions server-wide.
coerceInputsbooleanfalseAutomatically cast stringified arguments to schema types.
backgroundbooleanfalseStarts this server as a detached Unitup background daemon.
registerInCentralbooleantrueRegisters server in ~/.mcponce/servers.json.
middlewareArray[]Initial middleware pipeline handlers.

Environment Variables #

VariableDescription
PORTOverrides the HTTP port specified in options.
HOSTOverrides the host interface (e.g. 0.0.0.0 for Docker).
MCP_COERCE_INPUTSSet to true or 1 to enable smart input coercion globally.
MCP_DISABLE_REGISTRYSet to 1 to prevent registering in central servers.json.
MCP_DATA_DIRCustom directory path for all mcponce runtime files.
Updated