How to
How do I build an MCP server over my documents and media?
An MCP server over documents and media advertises search tools a client such as Claude or Cursor can call. One path is a hosted Cloud MCP that reads and operates a signed-in organization. The other is a Python server you run whose tools wrap similarity queries over your tables. Vendor video MCPs and FastMCP plus a vector database remain options.
Updated · Part of How do I ... in Python?
Before you start
About 20 min.
- Python 3.11+
- pip install -U 'pixeltable[serve]'
- pxt init in the project root
- mcp Python SDK
- sentence-transformers
- spacy and tiktoken for sentence,token_limit splitting
- torch and transformers for CLIP
1. Pick hosted Cloud MCP or a server you run
Hosted Cloud MCP connects Claude, Cursor, and other MCP clients to a signed-in organization. It lists databases and services, reads schemas and rows, and can start, stop, restart, retry, and set secrets. It cannot delete anything, run arbitrary queries, or invoke services, so it does not become your custom RAG server. A self-built Python MCP server wraps the queries you write over your tables. Vendor video MCPs and FastMCP plus a vector database are other options. Last reviewed November 2026.
2. Connect the hosted Cloud MCP
Connect the hosted remote Streamable HTTP endpoint. A client signs in with AuthKit and selects an organization. Follow the Cloud MCP hub, the Cursor guide, and the Claude images guide. That server operates the organization; it does not run the custom search queries this guide builds next.
# Claude Code# claude mcp add --transport http pixeltable-cloud --scope user https://www.pixeltable.com/mcp/cloud# Cursor: merge into ~/.cursor/mcp.json# {# "mcpServers": {# "pixeltable-cloud": { "url": "https://www.pixeltable.com/mcp/cloud" }# }# }
3. Declare tables and search queries you own
A self-built server needs something to query. Store documents and stills as typed columns, split PDFs into sentence windows, and index passage text and images. Hits return titles, captions, or chunk text, not file bytes. Apply the schema before the MCP process starts.
import pixeltable as pxtfrom pixeltable.functions.document import document_splitterfrom pixeltable.functions.huggingface import clip, sentence_transformerTableModel = pxt.model_base()clip_embed = clip.using(model_id='openai/clip-vit-base-patch32')text_embed = sentence_transformer.using(model_id='all-MiniLM-L6-v2')class Docs(TableModel, name='docs'):title: pxt.Stringdocument: pxt.Documentclass Chunks(TableModel,name='chunks',base=Docs,iterator=document_splitter(document=Docs.document,separators='sentence,token_limit',limit=300,),):__indexes__ = [pxt.EmbeddingIndex(text, string_embed=text_embed),]class Images(TableModel, name='images'):title: pxt.Stringimage: pxt.Imagecaption: pxt.String | None__indexes__ = [pxt.EmbeddingIndex(image, embedding=clip_embed),]# pxt init# pxt schema update app.py media -f
4. Wrap a query with MCPServer
from mcp.server.mcpserver import MCPServer is the current SDK entry. Decorate a function with @mcp.tool(). Inside, run similarity on the live table and format the rows, as the JFK files sample does for document summaries. The library has no API that turns your tables into a server; this process is the server. pxt.mcp_udfs is the other direction: it turns a server's tools into functions a column can call.
import pixeltable as pxtfrom mcp.server.mcpserver import MCPServermcp = MCPServer('MediaRAG')@mcp.tool()def search_documents(query: str, limit: int = 5) -> str:"""Semantic search over PDF chunks. Returns passage text and scores."""chunks = pxt.get_table('media.chunks')sim = chunks.text.similarity(string=query)hits = (chunks.order_by(sim, asc=False).limit(limit).select(chunks.text, sim=sim).collect())lines = [f"{i}. score={row['sim']:.4f}\n{row['text']}" for i, row in enumerate(hits)]return '\n\n'.join(lines) if lines else 'No results found.'@mcp.tool()def search_images(query: str, limit: int = 5) -> str:"""Search stills by a sentence. Returns titles, captions, and scores, not image bytes."""images = pxt.get_table('media.images')sim = images.image.similarity(string=query)hits = (images.order_by(sim, asc=False).limit(limit).select(images.title, images.caption, sim=sim).collect())lines = [f"{i}. score={row['sim']:.4f} title={row['title']} caption={row['caption']}"for i, row in enumerate(hits)]return '\n'.join(lines) if lines else 'No results found.'
5. Run Streamable HTTP
mcp.run(transport streamable-http, stateless_http true) is the cookbook default and listens on http://localhost:8000/mcp. Point Claude or Cursor at that URL as a remote MCP server. The JFK files sample also shows an older SSE Starlette wrapper. Use Streamable HTTP for a new server. Apply the schema before you start the process.
if __name__ == '__main__':mcp.run(transport='streamable-http', stateless_http=True)# Claude Code, after the process is listening:# claude mcp add --transport http media-rag --scope user http://localhost:8000/mcp
MCP over documents and media, last reviewed November 2026
| Hosted Cloud MCP | Self-built MCPServer | Vendor media MCPs | FastMCP plus vector DB | |
|---|---|---|---|---|
| Talks to | A signed-in Cloud organization | Your tables and queries | Mixpeek, Twelve Labs, or VideoDB APIs | Qdrant, Weaviate, or LanceDB you run |
| Tools | List, read, start, stop, restart, retry, set secrets | The search functions you wrap | Their hosted video or image APIs | The search functions you write |
| Custom RAG over your files | No; it cannot run arbitrary queries | Yes | Only over assets they host | Yes, if you glue ingest and index |
| Auth | AuthKit on the hosted endpoint | Whatever you put on the process | Their keys | Yours |
| Pick when | Operate Cloud from Claude or Cursor | MCP RAG over files you own | You already use that vendor | That vector database is already the contract |
Where Pixeltable fits
Pixeltable is the unified multimodal AI backend those MCP tools query. Hosted Cloud MCP at /mcp/cloud reads and operates a signed-in Cloud organization after AuthKit consent; ?read_only=true leaves only the read tools. It cannot delete anything, run arbitrary queries, or invoke services, and it does not run your search functions. A self-built MCPServer wraps those queries, as in the JFK files sample and the tool-calling cookbook. Pixeltable is also an MCP client: pxt.mcp_udfs turns a server's tools into functions a column can call. Mixpeek, Twelve Labs, and VideoDB publish vendor MCPs over their hosted media APIs. FastMCP plus Qdrant, Weaviate, or LanceDB is the glue stack when that vector database is already the contract. Last reviewed November 2026.
import pixeltable as pxtfrom mcp.server.mcpserver import MCPServerfrom pixeltable.functions.document import document_splitterfrom pixeltable.functions.huggingface import sentence_transformerTableModel = pxt.model_base()text_embed = sentence_transformer.using(model_id='all-MiniLM-L6-v2')class Docs(TableModel, name='docs'):title: pxt.Stringdocument: pxt.Documentclass Chunks(TableModel,name='chunks',base=Docs,iterator=document_splitter(document=Docs.document,separators='sentence,token_limit',limit=300,),):__indexes__ = [pxt.EmbeddingIndex(text, string_embed=text_embed),]mcp = MCPServer('MediaRAG')@mcp.tool()def search_documents(query: str, limit: int = 5) -> str:chunks = pxt.get_table('media.chunks')sim = chunks.text.similarity(string=query)hits = (chunks.order_by(sim, asc=False).limit(limit).select(chunks.text, sim=sim).collect())lines = [f"{i}. score={row['sim']:.4f}\n{row['text']}" for i, row in enumerate(hits)]return '\n\n'.join(lines) if lines else 'No results found.'if __name__ == '__main__':mcp.run(transport='streamable-http', stateless_http=True)
Questions
Does hosted Cloud MCP run my custom search queries?
How do I connect Claude or Cursor?
Is Pixeltable an MCP server for my tables?
How does this compare to Mixpeek, Twelve Labs, or VideoDB MCP?
Should I use FastMCP plus Qdrant instead?
Can Cloud MCP send image bytes to Claude?
Next step
Copy the commands into an agent, or run them locally with pip install pixeltable.