Skip to content

@McpServer, @McpTool & @McpExpose

@agboss/core/mcp provides three decorators for the Model Context Protocol (MCP): @McpServer (declares and supervises a connection to an external stdio or HTTP/SSE MCP server), @McpTool (wraps an external server’s tool in compile-checked TypeScript input/output DTOs and ToolHandler), and @McpExpose (exposes your own @Tool and @WorkflowStart classes as an MCP server via createMcpService(app, ConfigClass)).

Complete @McpServer, @McpTool, and @McpExpose example

Section titled “Complete @McpServer, @McpTool, and @McpExpose example”

What options do @McpServer, @McpTool, and @McpExpose accept?

Section titled “What options do @McpServer, @McpTool, and @McpExpose accept?”
Decorator Option Type Required Description
@McpServer name string Yes Unique identifier for the external MCP server ("workspace-fs-mcp").
@McpServer command / args or url string / readonly string[] Yes Launch command for stdio servers (command, args, env) or endpoint url for HTTP/SSE servers.
@McpServer tools ServerTools (Record<string, { input: DtoClass; output: DtoClass }>) Yes Map of upstream MCP tool names to their input and output DTO classes, typing this.server.call(toolName, args).
@McpTool name, description, input, output Same as @Tool Yes Exposes the MCP capability to @Agent({ tools: [...] }) with full DTO validation.
@McpTool server Class Yes The @McpServer class this tool calls; also listed in deps for constructor injection.
@McpTool deps readonly Token[] No Constructor dependencies including the @McpServer client class and ExecutionContext.
@McpExpose name string Yes Server name advertised to connecting MCP clients ("acme-support-mcp").
@McpExpose version string Yes Server version advertised over MCP ("1.0.0").
@McpExpose exports readonly Class[] Yes Array of @Tool and @WorkflowStart classes exposed over MCP.
Section titled “What related entities work with @McpServer, @McpTool, and @McpExpose?”
Related Entity Import Path Purpose
McpServerClient<TTools> "@agboss/core/mcp" Base class extended by @McpServer classes; provides this.call(toolName, input) with compile-checked arguments and return types.
@Workflow({ mcp: [ServerClass] }) "@agboss/core" Registers @McpServer classes on the workflow so the container connects them on startup and closes them on shutdown.
createMcpService(app, ExposeConfigClass) "@agboss/core/mcp" Creates a stdio (service.connectStdio()) or session-based MCP server from a booted App and an @McpExpose class.
mcpServerStub(ServerClass, handlers) "@agboss/core/testing" Stubs an @McpServer in unit tests (testTool) without spawning an external process.