Skip to content

simple-webmcpMake your existing functions agent-ready

Wrap a JS/TS function with webmcp(fn). Keep your API — add a WebMCP capability on top. One function. Two interfaces.

simple-webmcp

One function. Two interfaces. ​

ts
import { webmcp } from 'simple-webmcp';

async function searchCustomers({ query, limit = 20 }: { query: string; limit?: number }) {
  return customers.filter(c => c.name.includes(query)).slice(0, limit);
}

const search = webmcp(searchCustomers);

Human:

ts
await search({ query: 'alice' });

Agent (when mounted):

ts
import { useWebMCP } from 'simple-webmcp/react';
function Page() {
  const tool = useWebMCP(search, { description: 'Search customers' });
  return <UI />;
}

Customize only what you need:

ts
const search2 = webmcp(searchCustomers, {
  description: 'Search customers by name or email',
  fields: { query: { description: 'Name, email, or ID' } }
});

Progressive adoption: webmcp(fn) → add description → fields → schema (Zod) → build-time inference. For real cross-browser WebMCP use @mcp-b/webmcp-polyfill; simple-webmcp/dev-polyfill is for tests.

v0.1 is validated — webmcp(), useWebMCP(), Scope, polyfill, 42 tests. unplugin (0.2) and webmcp.server() for Next.js (0.3) are deferred behind spike.

Released under the MIT License.