Skip to main content
McpServer is the root of your app: an Express-backed server whose methods return the server itself, so you chain your tool registrations off it and export the resulting type for generateHelpers.

Example

A server registers one tool, exports its type for the typed client hooks, and starts listening.
server.ts

Constructor

  • serverInfo your server’s name and version.
  • options forwarded to the MCP SDK server.
  • skybridgeOptions Skybridge-specific configuration:
json tunes the express.json() parser Skybridge pre-applies, for example to raise the default 100kb body-size limit. oauth is an OAuthConfig, usually from customProvider or a branded provider. When set, it mounts the well-known OAuth metadata and bearer-token verification on /mcp.

Properties

express

The underlying Express app, for custom routes, middleware, and settings. Register handlers before run().
Alpic Cloud routes traffic only to /mcp. Custom routes work locally and on self-hosted deployments.

Methods

Every method returns the server, so calls chain.

registerTool

Registers a tool, optionally bound to a view. See registerTool for the full config and handler.

use

Registers Express middleware on the underlying app, optionally scoped to a path. Mirrors app.use.

useOnError

Registers an Express error handler, optionally path-scoped, to run after the /mcp route. A default handler runs last, responding with a 500 JSON-RPC error when nothing else has sent a response.

mcpMiddleware

Wraps MCP requests and notifications: each middleware runs (request, extra, next), can inspect or short-circuit the call, and invokes next() to continue. Register it before run() or connect(); middleware runs in registration order, outermost first. An optional filter scopes which methods it runs for.

run

Starts the HTTP server: applies your middleware, mounts /mcp, and listens (default port 3000). On serverless platforms, export what it returns so the platform can route requests to it. See Deploy for the per-platform setup.

registerTool

Define the tools and views the server exposes

generateHelpers

Turn AppType into typed client hooks

requireBearerAuth

Require or optionally accept a signed-in user