Documentation Index
Fetch the complete documentation index at: https://docs.trychroma.com/llms.txt
Use this file to discover all available pages before exploring further.
The Package Search MCP Server is an MCP server designed to add ground truth context about code packages to AI agents. Our research demonstrates that by exposing the source code of a project’s dependencies to a model, we improve its performance on coding tasks and reduce its potential for hallucination. Chroma’s Package Search MCP server achieves this by exposing tools to allow the model to retrieve necessary context:
| Tool Name | Usage |
|---|
package_search_grep | Use regex pattern matching to retrieve relevant lines from source code |
package_search_hybrid | Use semantic search with optional regex filtering to explore source code without existing knowledge of its structure |
package_search_read_file | Reads specific lines from a single file in the code package |
Getting Started
To guarantee that your model uses package search when desired, add use package search to either the system prompt (to use the MCP server whenever applicable) or to each task prompt (to use it only when you instruct the model to do so).
Anthropic SDK
OpenAI SDK
Google Gemini SDK
Claude Code
Codex
Cursor
Windsurf
Claude Desktop
Warp
Open Code
Ollama
MCP SDK
Roo Code
Click “Get API Key” to create or log into your Chroma account and issue an API key for Package Search.
After issuing your API key, click the “Other” tab and copy your API key.
Connect to the Chroma MCP server to search code packages. In this example, we search for how the Fast Fourier Transform algorithm is implemented in the numpy package from PyPI.
import anthropic
client = anthropic.Anthropic(
api_key="<YOUR_ANTHROPIC_API_KEY>"
)
response = client.beta.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=1000,
messages=[
{
"role": "user",
"content": "Explain how numpy implements its FFT. Use package search.",
}
],
mcp_servers=[
{
"type": "url",
"url": "https://mcp.trychroma.com/package-search/v1",
"name": "package-search",
"authorization_token": "<YOUR_CHROMA_API_KEY>",
}
],
betas=["mcp-client-2025-04-04"],
)
print(response)
Click “Get API Key” to create or log into your Chroma account and issue an API key for Package Search.
After issuing your API key, click the “Other” tab and copy your API key.
Connect to the Chroma MCP server to search code packages. In this example, we search for class definitions in the numpy package from PyPI.
from openai import OpenAI
client = OpenAI(
api_key="<YOUR_OPENAI_API_KEY>"
)
resp = client.responses.create(
model="gpt-5-chat-latest",
input="Explain how numpy implements its FFT. Use package search.",
tools=[
{
"type": "mcp",
"server_label": "package-search",
"server_url": "https://mcp.trychroma.com/package-search/v1",
"headers": {
"x-chroma-token": "<YOUR_CHROMA_API_KEY>"
},
"require_approval": "never",
}
],
)
print(resp)
Click “Get API Key” to create or log into your Chroma account and issue an API key for Package Search.
After issuing your API key, click the “Other” tab and copy your API key.
Connect the Chroma MCP server with Gemini to enable AI-powered code searches. In this example, we ask Gemini to explain how the Fast Fourier Transform algorithm is implemented in numpy, using the Chroma MCP tools to search and analyze the code.
import asyncio
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client
from google import genai
client = genai.Client(api_key="<YOUR_GEMINI_API_KEY>")
async def run():
async with streamablehttp_client(
"https://mcp.trychroma.com/package-search/v1",
headers={"x-chroma-token": "<YOUR_CHROMA_API_KEY>"},
) as (read, write, _):
async with ClientSession(read, write) as session:
await session.initialize()
try:
prompt = f"Explain how numpy implements its FFT. Use package search."
response = await client.aio.models.generate_content(
model="gemini-2.5-flash",
contents=prompt,
config=genai.types.GenerateContentConfig(
temperature=0,
tools=[session],
),
)
try:
if response.text:
print("--- Generated Text ---")
print(response.text)
else:
print("Model did not return text.")
print(f"Finish Reason: {response.candidates[0].finish_reason.name}")
except ValueError:
print("Could not access response.text.")
except Exception as e:
print(f"An error occurred: {e}")
asyncio.run(run())
Click “Get API Key” to create or log into your Chroma account and issue an API key for Package Search.
After issuing your API key, click the “Other” tab and copy your API key.
Add the Chroma MCP server to Claude Code with your Chroma API key:
claude mcp add --transport http package-search https://mcp.trychroma.com/package-search/v1 --header "x-chroma-token: <YOUR_CHROMA_API_KEY>"
Click “Get API Key” to create or log into your Chroma account and issue an API key for Package Search.
After issuing your API key, click the “Other” tab and copy your API key.
Add the following to your ~/.codex/config.toml file with your Chroma Cloud API key:
[mcp_servers.package-search]
command = "npx"
args = ["mcp-remote", "https://mcp.trychroma.com/package-search/v1", "--header", "x-chroma-token: ${X_CHROMA_TOKEN}"]
env = { "X_CHROMA_TOKEN" = "<YOUR_CHROMA_API_KEY>" }
Click “Get API Key” to create or log into your Chroma account and issue an API key for Package Search.
After issuing your API key, click the “Other” tab and copy your API key.
In Cursor’s settings, search for “MCP” and add the following configuration with your Chroma Cloud API key:
{
"mcpServers": {
"package-search": {
"transport": "streamable_http",
"url": "https://mcp.trychroma.com/package-search/v1",
"headers": {
"x-chroma-token": "<YOUR_CHROMA_API_KEY>"
}
}
}
}
Click “Get API Key” to create or log into your Chroma account and issue an API key for Package Search.
After issuing your API key, click the “Other” tab and copy your API key.
In Windsurf’s settings, search for “MCP” and add the following configuration with your Chroma Cloud API key:
{
"mcpServers": {
"package-search": {
"serverUrl": "https://mcp.trychroma.com/package-search/v1",
"headers": {
"x-chroma-token": "<YOUR_CHROMA_API_KEY>"
}
}
}
}
Click “Get API Key” to create or log into your Chroma account and issue an API key for Package Search.
After issuing your API key, click the “Other” tab and copy your API key.
Add the following to your ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"package-search": {
"command": "npx",
"args": ["mcp-remote", "https://mcp.trychroma.com/package-search/v1", "--header", "x-chroma-token: ${X_CHROMA_TOKEN}"],
"env": {
"X_CHROMA_TOKEN": "<YOUR_CHROMA_API_KEY>"
}
}
}
}
Click “Get API Key” to create or log into your Chroma account and issue an API key for Package Search.
After issuing your API key, click the “Other” tab and copy your API key.
Add the following to your Warp MCP config. Make sure to click “Start” on the server after adding.
{
"package-search": {
"command": "npx",
"args": ["mcp-remote", "https://mcp.trychroma.com/package-search/v1", "--header", "x-chroma-token: ${X_CHROMA_TOKEN}"],
"env": {
"X_CHROMA_TOKEN": "<YOUR_CHROMA_API_KEY>"
}
}
}
Click “Get API Key” to create or log into your Chroma account and issue an API key for Package Search.
After issuing your API key, click the “Other” tab and copy your API key.
Add the following to your ~/.config/opencode/opencode.json file with your Chroma Cloud API key:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"code-packages": {
"type": "remote",
"url": "https://mcp.trychroma.com/package-search/v1",
"enabled": true,
"headers": {
"x-chroma-token": "<YOUR_CHROMA_API_KEY>"
}
}
}
}
Click “Get API Key” to create or log into your Chroma account and issue an API key for Package Search.
After issuing your API key, click the “Other” tab and copy your API key.
Install the ollmcp package:
Create an mcp_config.json file with the following content and your Chroma Cloud API key:
{
"mcpServers": {
"code-packages": {
"type": "streamable_http",
"url": "https://mcp.trychroma.com/package-search/v1",
"headers": {
"x-chroma-token": "<YOUR_CHROMA_API_KEY>"
},
"disabled": false
}
}
}
Start an Ollama MCP session with the path to your mcp_config.json file and model of choice:
ollmcp --servers-json <path/to/mcp_config.json> --model <model>
Click “Get API Key” to create or log into your Chroma account and issue an API key for Package Search.
After issuing your API key, click the “Other” tab and copy your API key.
Connect to the Chroma MCP server to search code packages. In this example, we search for the Fast Fourier Transform function in the numpy package from PyPI using the package_search_grep tool.
import asyncio
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client
async def main():
async with streamablehttp_client(
"https://mcp.trychroma.com/package-search/v1",
headers={"x-chroma-token": "<YOUR_CHROMA_API_KEY>"},
) as (
read_stream,
write_stream,
_,
):
async with ClientSession(read_stream, write_stream) as session:
await session.initialize()
tools = await session.list_tools()
result = await session.call_tool(
name="package_search_grep",
arguments={
"package_name": "numpy",
"registry_name": "py_pi",
"pattern": "\bdef fft\b",
},
)
print(f"Got result: {result}")
print(f"Available tools: {[tool.name for tool in tools.tools]}")
asyncio.run(main())
Click “Get API Key” to create or log into your Chroma account and issue an API key for Package Search.
After issuing your API key, click the “Other” tab and copy your API key.
Add this to your Roo Code MCP server configuration:
{
"mcpServers": {
"code-collections": {
"type": "streamable-http",
"url": "https://mcp.trychroma.com/package-search/v1",
"headers": {
"x-chroma-token": "<YOUR_CHROMA_API_KEY>"
}
}
}
}