View the source code for this module on GitHub: https://github.com/mcp-use/mcp-use/blob/main/libraries/typescript/packages/mcp-use/src/server/types/common.ts
ServerConfig is the configuration object passed to the new MCPServer({ ... }) constructor. It controls server identity (name, version, title, icons), networking (host, base URL, CORS, DNS rebinding protection), session and stream persistence, OAuth authentication, and the public landing page. name and version are the only required fields; every other field is optional.
ServerConfig
Configuration for an MCP server. Pass this object to thenew MCPServer({ ... }) constructor.
MCPServer constructor. The constructor stores this object on server.config and applies the defaults described below. The new MCPServer(config) path takes a ServerConfig with name and version required; everything else is optional.
Properties
Type definitionUnique identifier for the MCP server (for example"my-mcp-server"or"product-search-api"). Required.Semantic version of the server (for example"1.0.0"). Required.Human-readable description of what the server does. Shown to clients during discovery. Optional, no default.Instructions for AI models using this server. Use this for server-wide guidance such as cross-tool workflows, ordering constraints, or safety requirements. Do not repeat individual tool descriptions here. Optional, no default.Hostname for widget URLs and server endpoints. When omitted, the constructor falls back to"localhost"(config.host || "localhost").Full base URL that overrideshost:portfor widget URLs (for example"https://myserver.com"). Use when deploying behind a reverse proxy or to a known public URL. Optional, no default.Custom CORS options for the server, typed against Hono’scorsmiddleware options. By default mcp-use enables permissive CORS (origin: "*") for development ergonomics. Set this to customize allowed origins, headers, methods, credentials, etc. Optional, no default.Allowed origins for DNS rebinding protection. If not set, protection is disabled (allHostvalues accepted). If set to an empty array, protection is also disabled. If set with one or more origins,Hostvalidation is enabled globally for the server. Optional, no default (disabled).Idle timeout for sessions in milliseconds. Defaults to86400000(1 day).Deprecated and slated for removal in a future version. Modern MCP clients send a newInitializeRequestafter receiving a 404 for a stale session, and the server now follows the spec strictly by returning 404 for invalid session IDs. For session persistence across restarts, usesessionStorewith a persistent backend instead. Optional, no default.Enable stateless mode (no session tracking). When leftundefined, the constructor auto-detects:truefor Deno (edge runtimes) andfalsefor Node.js. In Node.js, mode is further auto-detected per request from the clientAcceptheader (application/json, text/event-streamselects stateful;application/jsononly selects stateless). Settingstateless: trueforces stateless mode and ignores theAcceptheader. Stateless mode is required for edge functions where instances do not persist; stateful mode supports sessions, resumability, and notifications.Custom session metadata storage backend. Stores serializable session metadata (client capabilities, log level, timestamps); for active SSE stream management usestreamManagerinstead. Enables pluggable persistence for metadata survival across restarts, distributed deployments, and horizontal scaling. Defaults toFileSystemSessionStorewhenNODE_ENV !== "production"andInMemorySessionStorein production mode. Imported asimport("../sessions/stores/index.js").SessionStore.Custom stream manager for active SSE connections, separate fromsessionStoreto enable distributed notifications via Redis Pub/Sub. Manages active SSE stream controllers for server-to-client push notifications. Defaults to an in-memoryInMemoryStreamManager(streams on this server only). UseRedisStreamManagerfor distributed notifications and sampling across multiple instances. Imported asimport("../sessions/streams/index.js").StreamManager.OAuth authentication configuration. When provided, automatically sets up OAuth routes (/authorize,/token,.well-known/*), JWT verification middleware, bearer token authentication on all/mcproutes, and user information extraction with context attachment. Build with the provider factory functionsoauthSupabaseProvider(),oauthAuth0Provider(),oauthKeycloakProvider(), oroauthCustomProvider(). Optional, no default.Expose the HTML MCP landing page without bearer authentication. When OAuth is configured,/mcproutes require a token by default; set totrueto allow unauthenticated browser visits to the landing page while keeping MCP protocol traffic protected. Defaults tofalse.Path to a favicon file relative to thepublic/directory (for example"favicon.ico"or"icons/app-icon.png"). The favicon is automatically included in all widget pages. If omitted buticonsis provided, the constructor auto-selects a favicon fromicons. Optional, no default.Display name for the server, shown in MCP clients and the inspector UI. If not provided, thenamefield is used as the display name. Optional, no default.Website URL for the server (for example"https://myserver.com"), included in the server info displayed to clients. Optional, no default.Array of server icons in various sizes and formats, used by MCP clients and the inspector UI for server branding. Each entry requiressrcand may includemimeType,sizes, andtheme("light"or"dark"). Relativesrcvalues are rewritten to absolute URLs under${baseUrl}/mcp-use/public/whenbaseUrlis set. Optional, no default.
Usage
Thename and version fields are required; everything else is optional. The following example sets a display title and a baseUrl.
DNS rebinding protection
SetallowedOrigins to enable global Host header validation. Leaving it unset (or passing an empty array) disables protection and accepts all Host values.
See also
- MCPServer for the constructor that consumes
ServerConfig.