/tsed:tsed-mcp-serverfrom Ts.ED
Exposes MCP tools, resources, and prompts from a Ts.ED v8 application using @tsed/platform-mcp. Helps with configuration, decorators, error handling, client registration, proxying, and OAuth protection.
Ships in Ts.ED. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
@tsed/platform-mcp turns Ts.ED providers into MCP tools, resources and prompts. Handlers run inside the Ts.ED injector, so they reuse the application's services.
Read the API reference for option tables, resources, prompts and error payloads, and the standalone and clients reference for stdio servers and client registration, and the gateway and OAuth reference for proxying a third-party MCP server and protecting the endpoint. This skill is about the MCP server your application exposes; the MCP server shipped by the Ts.ED CLI belongs to the sibling skill tsed-cli.
Run npm install @tsed/platform-mcp, then import it in Server.ts:
import "@tsed/platform-express";
import "@tsed/platform-mcp";
import {Configuration} from "@tsed/di";
import {OrderTools} from "./mcp/OrderTools.js";
import {docsResource} from "./mcp/docsResource.js";
@Configuration({
mcp: {
path: "/mcp",
name: "orders",
version: "1.0.0",
tools: [OrderTools],
resources: [docsResource]
}
})
export class Server {}
POST <path> (default /mcp). The transport is stateless: a new MCP server is created per request.name and version fall back to the root name / version configuration, then to tsed-mcp / 0.0.0.enabled: false to skip an endpoint; use an array (mcp: [{name, path, tools}, ...]) to expose several independent servers.A decorator or a define* call alone exposes nothing. List each decorated class and each define* token in the tools, resources or prompts array of every server that should expose it. A class contributes all of its decorated methods of that kind.
import {Injectable, inject} from "@tsed/di";
import {Tool} from "@tsed/platform-mcp";
import {Description, Property, Required, Returns} from "@tsed/schema";
import {OrdersService} from "../services/OrdersService.js";
class GetOrderInput {
@Required()
@Description("Order identifier")
id: string;
}
class OrderResult {
@Property()
status: string;
}
@Injectable()
export class OrderTools {
protected orders = inject(OrdersService);
@Tool("get-order")
@Description("Returns one order by id")
@Returns(200, OrderResult)
async getOrder(input: GetOrderInput) {
return this.orders.get(input.id);
}
}
@Returns(200, Model). Omit it and no outputSchema is advertised.@Description; the name from @Tool(name) or the method name. Pass title, annotations or explicit schemas as @Tool(name, {...}).content (JSON text) and structuredContent. Return a full MCP result ({content: [...]}) only for custom content.tsed-models.import {inject} from "@tsed/di";
import {defineTool} from "@tsed/platform-mcp";
import {s} from "@tsed/schema";
import {OrdersService} from "../services/OrdersService.js";
export const cancelOrderTool = defineTool({
name: "cancel-order",
description: "Cancels an order that is not shipped yet",
inputSchema: s.object({id: s.string().required().description("Order identifier")}),
outputSchema: s.object({status: s.string().required()}),
async handler({id}) {
return {status: await inject(OrdersService).cancel(id)};
}
});
defineTool returns a DI token; add it to mcp.tools. Call inject() inside the handler, not at module top level.@Resource / defineResource) and prompts (@Prompt / definePrompt) follow the same two styles; see the reference.MCP_TOOL_ERROR, MCP_RESOURCE_ERROR, MCP_PROMPT_ERROR) and converted to a payload.isError: true with structuredContent: {status_code, code, message, tool}.code is E_MCP_<KIND>_<ERROR_NAME> when the error has both name and status (any @tsed/exceptions class, e.g. NotFound gives E_MCP_TOOL_NOT_FOUND); otherwise E_MCP_<KIND>_ERROR.@tsed/exceptions errors (sibling skill tsed-exceptions) with messages safe to show to a model; the message is returned verbatim. Arguments that violate the input schema are rejected by the MCP SDK before the handler runs.Use mcpServerConnect("stdio" | "streamable-http") from @tsed/platform-mcp/cli once the injector is loaded. It reads a single mcp configuration object (an array throws). Full scripts are in the reference.
stdio, stdout belongs to the protocol. Never call console.log; send diagnostics to stderr. The helper stops the Ts.ED logger before connecting.streamable-http serves POST /mcp on PORT (default 3000), ignores mcp.path, and needs express installed.Unit-test a tool through its token, inside PlatformTest.create() / PlatformTest.reset() (from @tsed/platform-http/testing):
const tool = inject<any>(cancelOrderTool);
const result = await tool.handler({id: "42"}, {} as any);
expect(result.structuredContent).toEqual({status: "cancelled"});
A failing handler resolves with result.isError === true; it does not reject. For an end-to-end check, bootstrap with PlatformTest.bootstrap(Server) and POST /mcp a JSON-RPC body with SuperTest (full example in the reference). Mocking services follows the sibling skill tsed-testing.
Add the HTTP endpoint ({"type": "http", "url": "http://localhost:8083/mcp"}) or the stdio command to .mcp.json under mcpServers for Claude Code, or to a [mcp_servers.<name>] table in Codex config.toml. Exact snippets are in the reference.
Add upstream to an mcp entry to serve a third-party MCP server (Streamable HTTP, SSE, or a stdio process such as an npx server) through the Ts.ED endpoint, and auth to protect the entry with an OAuth authorization server. Forward the caller's token with the ${OAUTH_TOKEN} placeholder in the upstream headers, or args/env for stdio. Option tables and startup errors are in the reference.
mcp: [
{
path: "/mcp/directus",
auth: {issuer: "https://auth.example.com", resource: "https://api.example.com/mcp/directus", requiredScopes: ["mcp:read"]},
upstream: {type: "http", url: "https://directus.example.com/mcp", headers: {Authorization: "Bearer ${OAUTH_TOKEN}"}}
}
];
@Tool, @Resource or @Prompt to auto-register; list the class in the mcp configuration.MCP:TOOL:<name>), so two definitions collide.auth option (OAuth, or a custom check such as an API key with auth.preAuth) rather than a global middleware testing the path.${OAUTH_TOKEN} inside a template literal (backticks): it is a plain-string placeholder resolved per request, not a JavaScript interpolation.mcp entry; use one entry per upstream.@tsed/common or from @modelcontextprotocol/sdk; the package uses @modelcontextprotocol/server and @modelcontextprotocol/node.tools/list: the class or token is not in mcp.tools of that server, @tsed/platform-mcp is not imported, or the class lacks @Injectable().@tsed/schema decorator.@Prompt gets no arguments schema from its parameter; pass argsSchema in the decorator options.POST <path> is served and the transport is stateless with JSON responses; GET and DELETE on the path answer 405 with Allow: POST. Clients that require sessions or a GET event stream are not served by the HTTP module.401 on every call in introspection mode: the authorization server does not return aud for the endpoint resource. Configure resource indicators on the authorization server, or set audience: false.typ: at+jwt with iss, exp, aud, sub, iat, jti, client_id). Use introspection or a custom verifier.tools/list: the upstream is unreachable (see the MCP_GATEWAY_UPSTREAM_ERROR log) or a local tool has the same name (MCP_GATEWAY_COLLISION).mcpServerConnect("stdio") fails with logger(...).stop is not a function unless a @tsed/logger instance is attached to the injector (attachLogger($log)).@tsed/platform-mcp is imported and every tool, resource and prompt is listed in mcp.s.object input schema, and an output schema.inject() and throw @tsed/exceptions errors.npx @modelcontextprotocol/inspector.Further reading: https://tsed.dev/docs/mcp.md.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub tsedio/tsed --plugin tsed13 skills in this plugin
/tsed-cliScaffolds Ts.ED v8 projects and generates files with the Ts.ED CLI v7, through its MCP server (tools set-workspace, init-project, list-templates, get-template, generate-file) or the tsed binary (tsed init, generate, template, add, run, update, dev, build). Use when creating a Ts.ED project, adding a controller, service, middleware, model, interceptor, pipe, decorator or custom template, when package.json has a "tsed" key or @tsed/cli, when a .templates/ directory exists, or on errors E_CWD_NOT_SET, E_PROJECT_NOT_INITIALIZED, E_TEMPLATE_UNKNOWN, E_ARGS_INVALID./tsed-configurationConfigure and bootstrap a Ts.ED v8 server - the @Configuration decorator or configuration() on the Server class, PlatformExpress/PlatformKoa/PlatformFastify.bootstrap, server options (mount, middlewares, httpPort, httpsPort, acceptMimes, logger, statics, views, responseFilters, imports), per-platform express/koa/fastify options, and @tsed/config sources (envs, dotenv, json, yaml). Use when editing Server.ts, index.ts or src/config, adding @tsed/config or the extends option, or reading settings with constant(), refValue(), @Constant, @Value or configuration().get()./tsed-controllersWrite Ts.ED v8 HTTP controllers and routes - @Controller paths and nested children, mounting through the `mount` configuration, verb decorators from @tsed/schema, parameter decorators from @tsed/platform-params, typed inputs, response decorators and custom endpoint decorators. Use when adding or fixing a REST endpoint, when a route returns 404 or is shadowed by another route, when @BodyParams/@QueryParams/@PathParams receive a plain object or the wrong type, or when working with @Returns, @Status, @Redirect, @View, @Hidden, @Req/@Res or useDecorators./tsed-diDeclare, inject and scope Ts.ED v8 providers and wire lifecycle hooks - @Injectable, @Module, @Controller, @Inject, the functional API (inject, injectMany, lazyInject, constant, refValue, injectable().factory/asyncFactory/class/value, injector, context, logger), ProviderScope, custom tokens, @tsed/hooks ($on, $emit, $asyncEmit, $alter) and request context. Use when writing services or modules with @tsed/di, fixing InjectionError, "Given token is undefined" or undefined injected properties, choosing a scope, adding $onInit/$onDestroy/$onReady, or replacing registerProvider and other deprecated DI APIs./tsed-docsLocates authoritative Ts.ED v8 documentation and API reference instead of guessing framework APIs. Routes a topic to the right tsed.dev page, its markdown twin, the llms.txt indexes (tsed.dev, cli.tsed.dev, logger.tsed.dev) and the sibling tsed-* skills. Use when working in a project that depends on @tsed/* packages and an import path, decorator (@Controller, @Injectable, @Returns), function (inject, injectable, configuration), option name or error message is uncertain, when an example imports from @tsed/common, or before answering any "how do I ... in Ts.ED" question./tsed-exceptionsHandle errors and shape responses in a Ts.ED v8 application with @tsed/exceptions, exception filters from @tsed/platform-exceptions and response filters from @tsed/platform-response-filter. Use when throwing BadRequest/NotFound/Unauthorized or a custom exception, customizing the JSON error payload, writing a @Catch filter, customizing the 404 ResourceNotFound page, wrapping all responses in an envelope with @ResponseFilter, documenting errors with @Returns(404, NotFound), or debugging responses such as "InternalServerError", AJV_VALIDATION_ERROR or a response filter that is never called.Other plugins' skills for the same job