Settings
Configure your server via constructor options or environment variables.
For most , pass options directly to ArcadeMCP. Use MCPSettings only when you need
to share configuration across multiple servers or load from a config file.
Quick Start
import { ArcadeMCP } from 'arcade-mcp-server';
const app = new ArcadeMCP({
name: 'my-server',
version: '1.0.0',
logLevel: 'DEBUG',
});Environment Variables
The SDK reads these environment variables as defaults. Constructor options take precedence.
Server Configuration
| Variable | Maps to | Example |
|---|---|---|
MCP_SERVER_NAME | name | "My Server" |
MCP_SERVER_VERSION | version | "1.0.0" |
MCP_SERVER_TITLE | title | "My Tools" |
MCP_SERVER_INSTRUCTIONS | instructions | "Use these tools to..." |
MCP_DEBUG | debug | true, false |
Runtime Configuration
These override app.run() options:
| Variable | Maps to | Example |
|---|---|---|
ARCADE_SERVER_TRANSPORT | transport | stdio, http |
ARCADE_SERVER_HOST | host | 0.0.0.0 |
ARCADE_SERVER_PORT | port | 8080 |
ARCADE_SERVER_RELOAD | reload | 0, 1 |
Middleware Configuration
| Variable | Maps to | Example |
|---|---|---|
MCP_MIDDLEWARE_LOG_LEVEL | logLevel | DEBUG, INFO, WARNING, ERROR, CRITICAL |
MCP_MIDDLEWARE_ENABLE_LOGGING | enableLogging | true, false |
MCP_MIDDLEWARE_ENABLE_ERROR_HANDLING | enableErrorHandling | true, false |
MCP_MIDDLEWARE_MASK_ERROR_DETAILS | maskErrorDetails | true, false |
Transport Configuration
| Variable | Maps to | Example |
|---|---|---|
MCP_TRANSPORT_SESSION_TIMEOUT_SECONDS | sessionTimeoutSeconds | 300 |
MCP_TRANSPORT_CLEANUP_INTERVAL_SECONDS | cleanupIntervalSeconds | 10 |
MCP_TRANSPORT_MAX_SESSIONS | maxSessions | 1000 |
MCP_TRANSPORT_MAX_QUEUE_SIZE | maxQueueSize | 1000 |
Notification Configuration
| Variable | Maps to | Example |
|---|---|---|
MCP_NOTIFICATION_RATE_LIMIT_PER_MINUTE | rateLimitPerMinute | 60 |
MCP_NOTIFICATION_DEFAULT_DEBOUNCE_MS | defaultDebounceMs | 100 |
MCP_NOTIFICATION_MAX_QUEUED_NOTIFICATIONS | maxQueuedNotifications | 1000 |
Arcade Integration
| Variable | Maps to | Example |
|---|---|---|
ARCADE_API_KEY | apiKey | arc_... |
ARCADE_API_URL | apiUrl | https://api.arcade.dev |
ARCADE_AUTH_DISABLED | authDisabled | true, false |
ARCADE_WORKER_SECRET | serverSecret | "secret_..." |
ARCADE_ENVIRONMENT | environment | dev, prod |
ARCADE_USER_ID | userId | "user_123" |
Access environment variables with Bun.env:
const debug = Bun.env.MCP_DEBUG === 'true';
const port = Number(Bun.env.ARCADE_SERVER_PORT) || 8000;MCPSettings
For advanced configuration, use the MCPSettings class:
import { MCPSettings } from 'arcade-mcp-server';
// Load from environment variables
const settings = MCPSettings.fromEnv();Or construct with explicit options:
import { MCPSettings } from 'arcade-mcp-server';
const settings = new MCPSettings({
debug: true,
server: {
name: 'My MCP Server',
version: '1.0.0',
title: 'My Tools',
instructions: 'Use these tools to manage documents.',
},
middleware: {
enableLogging: true,
enableErrorHandling: true,
logLevel: 'DEBUG',
maskErrorDetails: false,
},
transport: {
sessionTimeoutSeconds: 300,
cleanupIntervalSeconds: 10,
maxSessions: 1000,
maxQueueSize: 1000,
},
arcade: {
apiKey: Bun.env.ARCADE_API_KEY,
apiUrl: 'https://api.arcade.dev',
authDisabled: false,
environment: 'dev',
},
notification: {
rateLimitPerMinute: 60,
defaultDebounceMs: 100,
maxQueuedNotifications: 1000,
},
toolEnvironment: {
// Additional secrets available to tools
DATABASE_URL: Bun.env.DATABASE_URL,
REDIS_URL: Bun.env.REDIS_URL,
},
});Using with MCPServer
import { MCPServer, MCPSettings, ToolCatalog } from 'arcade-mcp-server';
const settings = MCPSettings.fromEnv();
const server = new MCPServer({
catalog: new ToolCatalog(),
settings,
});Getting Tool Secrets
const settings = MCPSettings.fromEnv();
// Get all secrets available to tools
const secrets = settings.toolSecrets();
// => { DATABASE_URL: '...', REDIS_URL: '...', ... }Settings Reference
MCPSettings
interface MCPSettings {
/** Enable debug mode (verbose logging, stack traces) */
debug?: boolean;
/** Server configuration */
server?: ServerSettings;
/** Middleware configuration */
middleware?: MiddlewareSettings;
/** Transport configuration (session/connection management) */
transport?: TransportSettings;
/** Arcade API configuration */
arcade?: ArcadeSettings;
/** Notification settings */
notification?: NotificationSettings;
/** Tool environment / secrets */
toolEnvironment?: ToolEnvironmentSettings;
}ServerSettings
interface ServerSettings {
/** Server name shown to AI clients */
name: string;
/** Server version */
version: string;
/** Human-readable title */
title?: string;
/** Usage instructions for AI clients */
instructions?: string;
}MiddlewareSettings
interface MiddlewareSettings {
/** Enable request logging (default: true) */
enableLogging?: boolean;
/** Enable error handling middleware (default: true) */
enableErrorHandling?: boolean;
/** Log level (default: 'INFO') */
logLevel?: 'DEBUG' | 'INFO' | 'WARNING' | 'ERROR' | 'CRITICAL';
/** Hide stack traces in error responses (default: false) */
maskErrorDetails?: boolean;
}TransportSettings
Session and connection management for HTTP transport:
interface TransportSettings {
/** Session timeout in seconds (default: 300) */
sessionTimeoutSeconds?: number;
/** Cleanup interval for expired sessions in seconds (default: 10) */
cleanupIntervalSeconds?: number;
/** Maximum concurrent sessions (default: 1000) */
maxSessions?: number;
/** Maximum queue size per session (default: 1000) */
maxQueueSize?: number;
}Transport type (stdio or http), host, and port are passed to app.run(), not stored in settings.
TransportSettings controls session behavior, not connection parameters.
ArcadeSettings
interface ArcadeSettings {
/** Arcade API key for auth and tool hosting */
apiKey?: string;
/** Arcade API URL (default: 'https://api.arcade.dev') */
apiUrl?: string;
/** Disable authentication (default: false) */
authDisabled?: boolean;
/** Server secret for worker endpoints (required to enable worker routes) */
serverSecret?: string;
/** Environment: 'dev' or 'prod' (default: 'dev') */
environment?: 'dev' | 'prod';
/** User ID for Arcade environment */
userId?: string;
}NotificationSettings
Rate limiting and queuing for client notifications:
interface NotificationSettings {
/** Maximum notifications per minute per client (default: 60) */
rateLimitPerMinute?: number;
/** Default debounce time in milliseconds (default: 100) */
defaultDebounceMs?: number;
/** Maximum queued notifications per client (default: 1000) */
maxQueuedNotifications?: number;
}ToolEnvironmentSettings
Environment variables available as secrets to :
interface ToolEnvironmentSettings {
/** Key-value pairs of secrets */
[key: string]: string | undefined;
}Any environment variable not prefixed with MCP_ or starting with _ is automatically
available as a secret via getSecret().
Configuration Precedence
Settings are resolved in this order (first wins):
- Constructor options /
app.run()options MCPSettingsobject- Environment variables
- Default values
Configuration Patterns
Development vs Production
import { ArcadeMCP } from 'arcade-mcp-server';
const isDev = Bun.env.NODE_ENV !== 'production';
const app = new ArcadeMCP({
name: 'my-server',
logLevel: isDev ? 'DEBUG' : 'INFO',
// In development, show full error details
// ErrorHandlingMiddleware reads this internally
});
app.run({
transport: 'http',
host: isDev ? '127.0.0.1' : '0.0.0.0',
port: Number(Bun.env.PORT) || 8000,
reload: isDev,
});Loading from Config File
import { MCPSettings } from 'arcade-mcp-server';
// Load from JSON file
const configFile = Bun.file('./config.json');
const config = await configFile.json();
const settings = new MCPSettings(config);Validating Configuration at Startup
import { ArcadeMCP } from 'arcade-mcp-server';
const requiredEnvVars = ['ARCADE_API_KEY', 'DATABASE_URL'];
for (const envVar of requiredEnvVars) {
if (!Bun.env[envVar]) {
throw new Error(`Missing required environment variable: ${envVar}`);
}
}
const app = new ArcadeMCP({ name: 'my-server' });Type-Safe Configuration
Use TypeScript’s satisfies for type-checked config objects:
import type { ArcadeMCPOptions } from 'arcade-mcp-server';
const config = {
name: 'my-server',
version: '1.0.0',
logLevel: 'DEBUG',
} satisfies ArcadeMCPOptions;
const app = new ArcadeMCP(config);