HttpApi MCP
An Effect MCP registrar and HTTP server driven by OpenAPI metadata, exposing selected HttpApi operations through the generated API client.
bunx --bun shadcn@latest add https://krakstack.net/r/httpapi-mcp.jsonOverview
httpapi-mcp turns operations selected by HttpApiSpec into MCP tools. Tool calls are delegated to ApiClient, keeping request encoding, authentication, transport overrides, and response decoding in the generated Effect HTTP API client. httpApiMcpServerLayer derives the MCP server name and version from the API OpenAPI info metadata.
Configure OpenAPI Metadata
Annotate the API with OpenApi.annotations({ title, version, description }). The same metadata drives API documentation, CLI identity, and MCP server identity.
Create An MCP Handler
Create an app-owned handler such as src/lib/mcp-handler.ts:
import { Layer } from "effect";
import { FetchHttpClient } from "effect/unstable/http";
import { AppApi } from "@/api";
import { env } from "@/env";
import { ApiClient } from "@/lib/httpapi-client";
import {
HttpApiMcp,
httpApiMcpServerLayer,
httpApiMcpToolsLayer,
} from "@/lib/httpapi-mcp";
import { HttpApiSpec } from "@/lib/httpapi-helpers";
const httpApiLayer = Layer.mergeAll(
HttpApiSpec.layer({ api: AppApi, methods: ["get"] }),
ApiClient.layer({
api: AppApi,
baseUrl: env.VITE_SITE_URL,
}).pipe(Layer.provide(FetchHttpClient.layer)),
);
const mcpToolsLayer = httpApiMcpToolsLayer.pipe(
Layer.provide(
HttpApiMcp.layer({
toolMetaKey: "app/httpapi",
}),
),
);
const mcpHttpLayer = httpApiMcpServerLayer("/api/mcp");
export const mcpLayer = Layer.mergeAll(mcpToolsLayer).pipe(
Layer.provideMerge(mcpHttpLayer),
Layer.provide(httpApiLayer),
);Provide mcpLayer from the application HTTP runtime alongside its API layers. Keep request-scoped authentication, telemetry, error mapping, and deployment-specific routing in this app-owned handler. For authentication, provide an app-owned HttpClient layer to ApiClient.layer; do not expose credentials as MCP tool inputs.
Exposed Operations
HttpApiSpec.layer controls which methods and operations become tools. Restrict MCP to get by default unless write operations and their approval policy are intentionally exposed.