Skip to content

Serve MCP over stdio and add an embeddings information resource - #1791

Open
adhikbuilds wants to merge 1 commit into
neuml:masterfrom
adhikbuilds:feat/mcp-stdio
Open

adhikbuilds wants to merge 1 commit into
neuml:masterfrom
adhikbuilds:feat/mcp-stdio

Conversation

@adhikbuilds

Copy link
Copy Markdown
Contributor

Closes #1779. Builds on #1763 and #1777.

Serve MCP over stdio

CONFIG=index.yml python -m txtai.api.mcp

This serves the same tools as /mcp over stdio, for MCP clients that start local servers as a subprocess (desktop and IDE assistants). It reads the same YAML config, so the mcp options such as tools, mcp_names and the annotations from #1777 all apply.

  • initialize is split into configure (load config, create the API instance, add routes) and createmcp. Building the FastMCP server moved into mcpserver, which both HTTP and stdio use.
  • Tools call the API in-process through FastMCP's ASGI transport, so there's no HTTP server, port or token. The stdio app is created without application dependencies such as TOKEN, because stdio has no request headers. The client that starts the process controls access to it, and the docs say so.

Embeddings information resource

txtai://embeddings/info is a read-only JSON resource with the document count, vector model path and dimensions, backend, and whether dense, sparse/keyword, content and graph are enabled. Only those fields are returned, never the full index config, since that can hold credentials such as database URLs.

Tests

  • testResource lists and reads the resource over streamable HTTP, and covers an API with no embeddings index.
  • testStdio runs main() with the TOOLS config, captures the server passed to run(transport="stdio"), then lists tools, calls the renamed total tool and reads the resource with an in-memory FastMCP client.
  • I also checked it end to end by starting python -m txtai.api.mcp as a subprocess with the MCP SDK's stdio client: it lists 16 tools and returns the resource, and stdout carries only protocol messages.

All 8 tests in testmcp.py pass. black and pylint are clean.

Docs

docs/api/mcp.md has new "Embeddings information" and "stdio" sections, with a client config example.

return server


def embeddingsinfo():

@davidmezzetti davidmezzetti Dec 6, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain more on what this adds? It seems clunky to have this defined here.

Perhaps api/base.py makes more sense? Or even app/base.py if it's general enough of a method past API usage.

And maybe another name so it's not confused with Embeddings.info() which like you said you wouldn't want to expose the entire config.

Do we need other ways to help with discovery when things like agents / workflows and pipelines are avaialble?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP: serve over stdio for local clients, and index info as a resource

2 participants