@infra-tools/agentic-ui-mcp
v1.3.0
Published
Expose @infra-tools/agentic-ui ToolDefs as a Model Context Protocol (MCP) server — Claude Desktop / Cursor / Zed / Continue / Windsurf can call your tools directly.
Maintainers
Readme
@infra-tools/agentic-ui-mcp
Expose @infra-tools/agentic-ui ToolDefs as a Model Context Protocol (MCP) server. The same tools your <mvk-chat-shell> invokes become callable from Claude Desktop, Cursor, Zed, Continue, Windsurf, and any other MCP-compatible host — without rewriting the handlers.
See ADR-006 for the design rationale.
Install
npm install @infra-tools/agentic-ui-mcpPeer dep: @infra-tools/agentic-ui (you'll already have it if you're publishing tools you wrote for the chat shell). zod is the validation library ToolDefs use.
Wrap your tools as an MCP server
// my-mcp-server.ts (run with `tsx`/`node`)
import { createMcpServer } from '@infra-tools/agentic-ui-mcp';
import { myTools } from './tools.js'; // your existing ToolDef[]
const server = createMcpServer({
name: 'my-server',
version: '0.1.0',
tools: myTools,
});
await server.start(); // stdio transport by default// ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"my-server": {
"command": "node",
"args": ["/absolute/path/to/my-mcp-server.js"]
}
}
}Restart Claude Desktop. Your tools are now in the tool picker.
What's exported
| Surface | Purpose |
|---------|---------|
| createMcpServer(opts) | Builds an MCP Server that exposes the given ToolDef[] as MCP tools. Returns a handle with start() / stop() |
| BeforeCallHook / AfterCallHook | Per-tool middleware seams — log every invocation, redact PII, fail closed on policy violations |
| formatToolResult(result) | Maps an agentic-ui tool result (text + render hints + components) into MCP ContentBlock[]. Emits a text/html resource with a ui:// URI (the MCP-UI convention) for inline-rendered HTML |
| zodToMcpSchema(schema, name) | Translates a Zod input schema into the JSON-Schema fragment MCP requires |
| syntheticToolContext({...}) | Builds a ToolContext shaped to satisfy your existing handler when invoked from MCP (no Component, no Backend — those are browser concerns) |
| MCP_UI_HTML_MIME | The text/html MCP-UI MIME constant for tools that return HTML render hints (matches the inbound renderer in @infra-tools/agentic-ui) |
Common patterns
Per-user audit attribution
const server = createMcpServer({
name: 'ediscovery',
version: '0.1.0',
tools,
beforeCall: async (ctx) => {
ctx.principal = await resolvePrincipal({
userId: process.env.MCP_USER_ID, // set per-user in env
mcpClient: ctx.clientInfo?.name ?? 'unknown',
});
},
afterCall: async (ctx, result) => {
auditChain.append({
tool: ctx.toolName,
principal: ctx.principal,
args: ctx.args,
result,
origin: 'mcp',
ts: new Date().toISOString(),
});
},
});Inline-rendering HTML in MCP hosts that support it
When a tool returns { ...result, renderHints: { html: '<...>' } }, formatToolResult emits a resource block with MIME text/html and a ui:// URI — the MCP-UI convention. MCP-UI–aware hosts render it inline in a sandboxed iframe; hosts without UI support fall back to the resource's plain-text representation.
Demos
examples/demo-ediscovery-mcp— five eDiscovery tools exposed via@infra-tools/agentic-ui-mcpfor analyst workstations. Phase 6 of the eDiscovery plan.examples/demo-mcp-server— minimal generic MCP server scaffold.
Full docs
- Cookbook: Expose your tools as an MCP server — install → wire
claude_desktop_config.json→ transport choices → before/after-call patterns → production checklist - Cookbook: Paralegal privilege review in Claude Desktop — end-to-end walkthrough with the eDiscovery flagship
- ADR-006 — MCP server-side adapter
Compatibility
| Tool | Version |
|------|---------|
| Node.js | ≥ 20.19 |
| TypeScript | 5.9+ |
| MCP SDK | ^1.0.0 (transitive via @modelcontextprotocol/sdk) |
