ai-mcp
БесплатноБез исполняемых скриптовНе проверенHost-side Model Context Protocol (MCP) for TanStack AI: connect to external MCP servers, host your own tools with createMCPServer, discover and run tools…
от TanStack★ 3 396 звёзд на GitHubОб этом скилле
@tanstack/ai-mcp
This skill covers the @tanstack/ai-mcp package. Read ai-core/tool-calling/SKILL.md
first — MCP tools flow into chat() the same way hand-written tools do.
If you host the tools yourself, use createMCPServer.
When to use this package
Use @tanstack/ai-mcp when:
- A third-party MCP server exposes tools you want an agent or chat loop to call.
- You want to read MCP server resources (files, text, data) or prompts into a
chat()message list. - You want generated TypeScript types for an external MCP server's tool
signatures (via the bundled
generateCLI). - You are running tool execution on the server side and want to connect to MCP servers with HTTP (Streamable HTTP or SSE) or stdio transports.
- You want to expose your own tools as an MCP server over HTTP or stdio.
Do NOT use this package for browser/client-side code — MCP connections are server-side only.
Install
pnpm add @tanstack/ai-mcp
The package has these subpaths:
.exportscreateMCPClient,createMCPClients, converters, and types../stdioexports the Node-only client transportstdioTransport../serverexportscreateMCPServer../server/stdioexportsserveMCPStdio../appsexportscreateMcpAppCallHandler../harnessexportscreateHarnessMcpServerand themcp()harness plugin.createHarnessMcpServerserves a TanStack AI harness as an MCP server. Seedocs/harness/mcp-server.md, and "mcp(): MCP servers in a harness" below../connectorexportsmcpConnector: one OAuth MCP server as a harness plugin. Seedocs/harness/mcp.md../eventsexportscreateMCPEventWebhook,inMemoryMCPEventStore, andcreateMCPEventSecret(experimental MCP Events / SEP-3415).
Import ./stdio and ./server/stdio only from Node code.
Those entries use Node I/O.
Host an MCP server
Import createMCPServer from @tanstack/ai-mcp/server.
Pass tools from toolDefinition().server().
Call server.fetch(request) in your HTTP route.
import { toolDefinition } from '@tanstack/ai'
import { createMCPServer } from '@tanstack/ai-mcp/server'
import { z } from 'zod'
const getWeather = toolDefinition({
name: 'get_weather',
description: 'Current weather for a city',
inputSchema: z.object({ city: z.string() }),
}).server(async ({ city }) => {
return { city, temperature: 18, conditions: 'clear' }
})
const server = createMCPServer({
name: 'weather',
version: '1.0.0',
tools: [getWeather],
})
export function handleMcp(request: Request) {
return server.fetch(request)
}
// Mount handleMcp on GET, POST, and DELETE.
// GET is the spec 2025 stream.
// DELETE closes a spec 2025 session.
createMCPServer speaks spec 2026-07-28.
createMCPServer also speaks spec 2025. By default it keeps no spec 2025 session.
Its tools, resources, and prompts are static. It advertises no list-change
capability and rejects subscriptions/listen with JSON-RPC -32601.
stdioTransport from @tanstack/ai-mcp/stdio connects your client to a command.
serveMCPStdio from @tanstack/ai-mcp/server/stdio serves your server on stdin and stdout.
Write logs with console.error.
stdout carries only protocol messages.
import { toolDefinition } from '@tanstack/ai'
import { createMCPServer } from '@tanstack/ai-mcp/server'
import { serveMCPStdio } from '@tanstack/ai-mcp/server/stdio'
import { z } from 'zod'
const getWeather = toolDefinition({
name: 'get_weather',
description: 'Current weather for a city',
inputSchema: z.object({ city: z.string() }),
}).server(async ({ city }) => {
return { city, temperature: 18, conditions: 'clear' }
})
const server = createMCPServer({
name: 'weather',
version: '1.0.0',
tools: [getWeather],
})
serveMCPStdio(server)
You can also pass resources and prompts.
Build them with resourceDefinition and promptDefinition from @tanstack/ai-mcp/server.
A resource read(uri, variables, ctx) gets the requested URI, the template variables, and ctx.context (the handle context plus authInfo).
A template resource can take list(ctx), which returns { resources } for resources/list.
A tool reads its hooks on ctx.context.
Give .server() the type MCPToolContext from @tanstack/ai-mcp/server.
Then ctx.context.requestInput and ctx.context.sample type-check.
On spec 2026, ctx.context.requestInput throws, and the handler returns input_required.
The client runs the tool again with the answer.
Code before requestInput runs on each call, so it can run more than once.
Put work that must run once after requestInput returns.
On spec 2026, a tool asks one question per call. A second requestInput throws an Error.
If the user declines or cancels, requestInput throws an Error, and the call ends with a tool error.
In an execution: 'task' tool, ctx.context.requestInput throws an error.
On spec 2025 with sessions: 'memory', requestInput waits on the open session. Without a sess
Установить ai-mcp в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл ai-mcp?
Host-side Model Context Protocol (MCP) for TanStack AI: connect to external MCP servers, host your own tools with createMCPServer, discover and run tools inside any adapter's chat() loop, read resources and prompts, generate TypeScript types (typed tool names/pool keys) with the bundled CLI, and manage lifecycle with close()/await using.
Как установить скилл ai-mcp?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл ai-mcp запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic