Basic Usage
import { FrontMcp } from '@frontmcp/sdk';
@FrontMcp({
info: { name: 'My Server', version: '1.0.0' },
apps: [MyApp],
})
export default class MyServer {}
Signature
function FrontMcp(providedMetadata: FrontMcpMetadata): ClassDecorator
Configuration Options
Required Properties
| Property | Type | Description |
|---|---|---|
info | ServerInfoOptions | Server metadata (name, version, description) |
apps | AppType[] | Array of app classes to register |
Server Configuration
| Property | Type | Default | Description |
|---|---|---|---|
serve | boolean | true | Auto-start HTTP server |
http | HttpOptionsInput | - | HTTP server configuration |
@FrontMcp({
info: { name: 'My Server', version: '1.0.0' },
apps: [MyApp],
serve: true,
http: {
port: 3000,
cors: { origin: '*' },
hostFactory: (config) => new ExpressHostAdapter(config),
},
})
Storage Configuration
| Property | Type | Description |
|---|---|---|
redis | RedisOptionsInput | Redis storage for sessions/state |
pubsub | PubsubOptionsInput | Pub/Sub for distributed events |
@FrontMcp({
info: { name: 'My Server', version: '1.0.0' },
apps: [MyApp],
redis: {
provider: 'redis',
host: 'localhost',
port: 6379,
keyPrefix: 'mcp:',
},
})
Transport Configuration
| Property | Type | Description |
|---|---|---|
transport | TransportOptionsInput | Session lifecycle settings |
@FrontMcp({
info: { name: 'My Server', version: '1.0.0' },
apps: [MyApp],
transport: {
distributedMode: true,
sessionTtl: 3600000, // 1 hour
},
})
Shared Components
| Property | Type | Description |
|---|---|---|
providers | ProviderType[] | Gateway-level providers |
tools | ToolType[] | Shared tools across all apps |
resources | ResourceType[] | Shared resources |
skills | SkillType[] | Shared skills |
plugins | PluginType[] | Server-level plugins |
@FrontMcp({
info: { name: 'My Server', version: '1.0.0' },
apps: [MyApp],
providers: [ConfigService, LoggingService],
plugins: [RememberPlugin, CachePlugin],
tools: [HealthCheckTool],
})
Feature Configuration
| Property | Type | Description |
|---|---|---|
logging | LoggingOptionsInput | Logging configuration |
pagination | PaginationOptions | List operation pagination |
elicitation | ElicitationOptionsInput | Interactive user input |
skillsConfig | SkillsConfigOptionsInput | Skills HTTP endpoints |
extApps | ExtAppsOptionsInput | MCP Apps widget configuration |
@FrontMcp({
info: { name: 'My Server', version: '1.0.0' },
apps: [MyApp],
logging: {
level: 'info',
transports: [{ type: 'console' }],
},
elicitation: {
enabled: true,
ttl: 300000, // 5 minutes
},
skillsConfig: {
enabled: true,
auth: 'api-key',
apiKeys: ['sk-xxx'],
},
})
Full Example
import { FrontMcp, App, Tool, ToolContext } from '@frontmcp/sdk';
import { RememberPlugin } from '@frontmcp/plugins';
import { z } from 'zod';
@Tool({
name: 'greet',
inputSchema: { name: z.string() },
})
class GreetTool extends ToolContext {
async execute(input: { name: string }) {
return `Hello, ${input.name}!`;
}
}
@App({
name: 'main',
tools: [GreetTool],
})
class MainApp {}
@FrontMcp({
info: {
name: 'Greeting Server',
version: '1.0.0',
description: 'A simple greeting MCP server',
},
apps: [MainApp],
serve: true,
http: { port: 3000 },
plugins: [RememberPlugin],
logging: { level: 'info' },
})
export default class GreetingServer {}
Bootstrap Methods
HTTP Server
import { FrontMcpInstance } from '@frontmcp/sdk';
import config from './server';
// Start HTTP server
await FrontMcpInstance.bootstrap(config);
Serverless Handler
import { FrontMcpInstance } from '@frontmcp/sdk';
import config from '../src/server';
// Export for Vercel/AWS Lambda
export default FrontMcpInstance.createHandler(config);
Stdio Transport
import { FrontMcpInstance } from '@frontmcp/sdk';
import config from './server';
// Connect via stdio (for Claude Desktop)
await FrontMcpInstance.runStdio(config);
Direct Client
import { FrontMcpInstance } from '@frontmcp/sdk';
import config from './server';
// Create direct programmatic access
const server = await FrontMcpInstance.createDirect(config);
const tools = await server.listTools();
Related
@App
Define application modules
FrontMcpInstance
Server lifecycle management