---
title: "How do I build an MCP server over my documents and media?"
description: "Build an MCP server over documents and media: hosted Cloud MCP for org reads and writes, or a Python MCPServer whose tools wrap your search queries."
url: "https://www.pixeltable.com/learn/how-to/build-an-mcp-server-over-your-media-files"
updated: "2026-11-23"
doc: "https://docs.pixeltable.com/howto/cookbooks/agents/llm-tool-calling"
---

# 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: 2026-11-23
Part of [How do I ... in Python?](https://www.pixeltable.com/learn/how-to).

## 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

## On this page

- [Before you start](https://www.pixeltable.com/learn/how-to/build-an-mcp-server-over-your-media-files#before-you-start)
- [Pick hosted Cloud MCP or a server you run](https://www.pixeltable.com/learn/how-to/build-an-mcp-server-over-your-media-files#step-1)
- [Connect the hosted Cloud MCP](https://www.pixeltable.com/learn/how-to/build-an-mcp-server-over-your-media-files#step-2)
- [Declare tables and search queries you own](https://www.pixeltable.com/learn/how-to/build-an-mcp-server-over-your-media-files#step-3)
- [Wrap a query with MCPServer](https://www.pixeltable.com/learn/how-to/build-an-mcp-server-over-your-media-files#step-4)
- [Run Streamable HTTP](https://www.pixeltable.com/learn/how-to/build-an-mcp-server-over-your-media-files#step-5)
- [Comparison](https://www.pixeltable.com/learn/how-to/build-an-mcp-server-over-your-media-files#comparison)
- [Where Pixeltable fits](https://www.pixeltable.com/learn/how-to/build-an-mcp-server-over-your-media-files#where-pixeltable-fits)
- [Questions](https://www.pixeltable.com/learn/how-to/build-an-mcp-server-over-your-media-files#questions)

## 1. Pick hosted Cloud MCP or a server you run {#step-1}

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 {#step-2}

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.

```python
# 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 {#step-3}

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.

```python
import pixeltable as pxt
from pixeltable.functions.document import document_splitter
from pixeltable.functions.huggingface import clip, sentence_transformer

TableModel = 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.String
    document: pxt.Document

class 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.String
    image: pxt.Image
    caption: 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 {#step-4}

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.

```python
import pixeltable as pxt
from mcp.server.mcpserver import MCPServer

mcp = 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 {#step-5}

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.

```python
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 {#comparison}

|  | 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 {#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.

```python
import pixeltable as pxt
from mcp.server.mcpserver import MCPServer
from pixeltable.functions.document import document_splitter
from pixeltable.functions.huggingface import sentence_transformer

TableModel = pxt.model_base()
text_embed = sentence_transformer.using(model_id='all-MiniLM-L6-v2')

class Docs(TableModel, name='docs'):
    title: pxt.String
    document: pxt.Document

class 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)
```

## Concepts

- [What is MCP?](https://www.pixeltable.com/learn/what-is-mcp)
- [What is agentic RAG?](https://www.pixeltable.com/learn/what-is-agentic-rag)
- [What is an agent harness?](https://www.pixeltable.com/learn/what-is-an-agent-harness)

## Use case

- [AI Agents & MCP: Give Your Agents Persistent Multimodal Memory](https://www.pixeltable.com/use-cases/ai-agents-mcp)

## Questions {#questions}

### Does hosted Cloud MCP run my custom search queries? {#faq-1}

No. It reads and operates a signed-in organization: schemas, up to 25 JSON rows, logs, start, stop, restart, retry, and set secrets after a preview. It cannot run arbitrary queries, invoke services, or delete anything. Custom RAG over your files is a self-built MCPServer that wraps those queries. See Pixeltable Cloud MCP.

### How do I connect Claude or Cursor? {#faq-2}

For hosted Cloud MCP, follow Connect Cursor to Pixeltable Cloud and Give Claude access to images with MCP. Both use https://www.pixeltable.com/mcp/cloud with AuthKit sign-in. For a self-built server, point the client at the Streamable HTTP URL your process listens on, such as http://localhost:8000/mcp.

### Is Pixeltable an MCP server for my tables? {#faq-3}

The library is an MCP client: pxt.mcp_udfs turns a server's tools into functions a column can call. There is no API that turns your tables into a server. You wrap queries with MCPServer, as the JFK files sample and the tool-calling cookbook do. Hosted Cloud MCP operates Cloud. Coding-agent MCPs (developer and memory) inspect a catalog; they are not media RAG servers.

### How does this compare to Mixpeek, Twelve Labs, or VideoDB MCP? {#faq-4}

Those vendors publish MCP servers over their hosted media APIs. Last reviewed November 2026; endpoints and pricing are on their sites. Pick them when you already use that API. Pick a self-built MCPServer when the files, the index, and the tool should live in one schema you own. Hosted Cloud MCP is for operating Cloud, not for replacing those vendor MCPs.

### Should I use FastMCP plus Qdrant instead? {#faq-5}

Use FastMCP plus Qdrant, Weaviate, or LanceDB when that vector database is already the contract and you will glue FFmpeg, an object store, and workers yourself. Wrapping queries with MCPServer keeps the files, the index, and the tool in one schema. The MCP Python SDK entry shown here is MCPServer, which the tool-calling cookbook uses.

### Can Cloud MCP send image bytes to Claude? {#faq-6}

No. get_table_rows returns JSON, at most 25 rows, with strings clipped. An Image column shows up as JSON, not pixels. If Claude must reason about a still, store a caption as a computed column, then let Claude read that text. Give Claude access to images with MCP is that walkthrough. A self-built tool can return captions the same way.

## Related

- [What is MCP?](https://www.pixeltable.com/learn/what-is-mcp)
- [What is agentic RAG?](https://www.pixeltable.com/learn/what-is-agentic-rag)
- [What is an agent harness?](https://www.pixeltable.com/learn/what-is-an-agent-harness)
- [AI agents and MCP](https://www.pixeltable.com/use-cases/ai-agents-mcp)
- [Backend for AI agents](https://www.pixeltable.com/backend-for-ai-agents)
- [Pixeltable Cloud MCP](https://www.pixeltable.com/developers/mcp-cloud)
- [Connect Cursor to Pixeltable Cloud](https://www.pixeltable.com/developers/mcp-cloud/connect-cursor)
- [Give Claude access to images with MCP](https://www.pixeltable.com/developers/mcp-cloud/give-claude-access-to-images)
- [How do I let an AI agent search my video library, images, and PDFs?](https://www.pixeltable.com/learn/how-to/give-an-ai-agent-multimodal-search-tools)
- [JFK files MCP server sample on GitHub](https://github.com/pixeltable/pixeltable/tree/main/docs/sample-apps/jfk-files-mcp-server)
- [Use tool calling and MCP servers with LLMs](https://docs.pixeltable.com/howto/cookbooks/agents/llm-tool-calling)
