Skip to content

MCP Server

AsiJS includes a built-in Model Context Protocol (MCP) server for AI/LLM assistants to inspect and interact with your application.

typescript
import { mcp, MCPServer } from "asijs";

// As a plugin (auto-starts MCP server)
app.plugin(mcp({
  port: 3100,
  name: "my-app-mcp",
}));

// Or standalone
const server = new MCPServer(app, { port: 3100 });
server.start();

Built-in Tools

ToolDescription
list_routesList all registered routes
get_route_detailsGet route info (validation, middleware)
get_pluginsList all registered plugins
get_middlewareGet middleware counts
get_openapiGenerate OpenAPI spec
get_app_stateGet app configuration
suggest_routesSuggest RESTful routes for a resource

Custom Tools & Resources

typescript
const server = new MCPServer(app, {
  tools: [
    {
      name: "get_stats",
      description: "Get app statistics",
      inputSchema: { type: "object", properties: {} },
      handler: async () => ({ uptime: process.uptime() }),
    },
  ],
  resources: [
    {
      uri: "asijs://custom/data",
      name: "Custom Data",
      contents: async () => JSON.stringify({ key: "value" }),
    },
  ],
});

Released under the MIT License.