integration · Astro

Astro MCP integration.

Your Astro 5 site already has server endpoints handling content, search, and form submissions — here's how to expose them as MCP tools an agent can call, without abandoning Astro's content-first model.

wmcp.sh is not affiliated with The Astro Technology Company or Anthropic. Astro and Astro server endpoints are Astro project features.

Astro endpoints are agent-callable. They just don't advertise it.

What you have today

Server endpoints under src/pages/api/*.ts exporting GET / POST handlers that take Astro.request and return a Response. They run under @astrojs/node, @astrojs/cloudflare, @astrojs/vercel, or another adapter.

What agents need

A discoverable MCP server with tool schemas. wmcp.sh reads an OpenAPI 3 document describing your endpoints and emits the MCP server at https://wmcp.sh/mcp/<your-id> — no Astro changes required.

An Astro endpoint, exposed as a tool.

Plain Astro 5; the OpenAPI bit is what wmcp.sh ingests.

// src/pages/api/search.ts — Astro 5 server endpoint
import type { APIRoute } from 'astro';
import { z } from 'zod';

export const prerender = false;

const Query = z.object({ q: z.string().min(2), limit: z.number().int().max(50).default(10) });

export const POST: APIRoute = async ({ request }) => {
  const input = Query.parse(await request.json());
  const results = await searchContent(input.q, input.limit);
  return new Response(JSON.stringify({ q: input.q, results }), {
    headers: { 'content-type': 'application/json' },
  });
};

// Publish OpenAPI at /openapi.json (hand-written, or generated from your Zod
// schemas with @asteasolutions/zod-to-openapi). Then point wmcp.sh at it.

Register the spec: curl 'https://wmcp.sh/api/v1/tools?url=https://acme.example.com/openapi.json'. Details at /integration/openapi.

Roll-your-own MCP vs wmcp.sh on Astro.

CapabilityHand-rolledwmcp.sh + Astro OpenAPI
Tool schemas ⚠️ Hand-write tools.ts, keep in sync with endpoint files ✅ Generated from OpenAPI; one source of truth
SSE / Streamable HTTP transport ⚠️ You build it ✅ Served at https://wmcp.sh/mcp/<your-id> with full MCP spec
Static-site compatibility ❌ Needs a runtime ⚠️ Still needs server endpoints — output: 'server' or 'hybrid'
Multi-adapter portability ⚠️ Tied to one adapter's runtime ✅ wmcp.sh proxies any HTTPS origin — Node, CF Pages, Vercel
Auth forwarding ⚠️ Per-endpoint middleware ✅ Bearer / API-key / OAuth 2.1 proxy
Spec drift detection ❌ Silent breakage ✅ Re-ingest on deploy; mismatches surface immediately

Common questions from Astro teams.

Can static Astro sites expose MCP tools?
Not directly — there's no runtime to call. You need output: 'server' or 'hybrid' in astro.config.mjs plus an adapter (Node, Cloudflare, Vercel). Static pages can still coexist; only endpoints need to be server-rendered.
How do I generate an OpenAPI spec from Astro endpoints?
Astro has no built-in generator. Pick one: hand-write src/pages/openapi.json.ts, use @asteasolutions/zod-to-openapi at build time, or factor handlers into Hono / tRPC sub-apps with their own generators.
Does this work on Cloudflare Pages?
Yes. wmcp.sh itself runs on Cloudflare Workers. Your Astro origin can run anywhere — Pages Functions, Workers, Node, Vercel, Netlify — as long as it answers HTTPS.
What about Astro Actions?
Actions are a typed RPC layer for first-party UI. They don't have stable public URLs, so for MCP you mirror the action logic in a regular endpoint with a URL the OpenAPI spec references.
How does authentication work?
Three patterns: bearer pass-through (wmcp.sh forwards Authorization), OAuth 2.1 DCR proxy at /mcp/<provider>, or per-tool API keys declared in your spec's securitySchemes.
Versions supported?
The example targets Astro 5. Anything from Astro 3+ that ships server endpoints with the APIRoute shape works identically.
Need this done for you?

Skip the wiring — we ship the OpenAPI + MCP for your Astro site.

Audit your endpoints, emit a typed spec, deploy MCP at mcp.yourbrand.com. Starter $499 one-time setup; Managed Retainer $999/mo for ongoing maintenance; Enterprise $4,999+/mo for SLA + private deploy.

See /managed → Submit (free)