DSAgent supports the Model Context Protocol (MCP) to connect to external tool servers, enabling capabilities like web search, database queries, file system access, and more.
MCP support requires the optional dependency:
pip install "datascience-agent[mcp]"Use the built-in templates to quickly add MCP servers:
# Add web search capability
dsagent mcp add brave-search
# You'll be prompted for your BRAVE_API_KEY
# Add file system access
dsagent mcp add filesystem
# You'll be prompted for paths to allow
# List configured servers
dsagent mcp list# Start chat with MCP tools enabled
dsagent --mcp-config ~/.dsagent/mcp.yamlThe agent can now use web search and other configured tools automatically.
MCP servers are configured in a YAML file (default: ~/.dsagent/mcp.yaml):
servers:
# Web search via Brave API
- name: brave_search
transport: stdio
command: ["npx", "-y", "@modelcontextprotocol/server-brave-search"]
env:
BRAVE_API_KEY: "${BRAVE_API_KEY}"
# Local file system access
- name: filesystem
transport: stdio
command: ["npx", "-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed"]
# GitHub repository access
- name: github
transport: stdio
command: ["npx", "-y", "@modelcontextprotocol/server-github"]
env:
GITHUB_TOKEN: "${GITHUB_TOKEN}"
# HTTP-based server (alternative transport)
- name: custom_server
transport: http
url: "http://localhost:8080/mcp"
enabled: false # Disable without removing| Field | Type | Description |
|---|---|---|
name |
string | Unique identifier for the server |
transport |
string | stdio or http |
command |
list | Command to start stdio server |
url |
string | URL for http transport |
env |
object | Environment variables for the server |
enabled |
boolean | Enable/disable without removing (default: true) |
Use ${VAR_NAME} syntax to reference environment variables:
env:
API_KEY: "${MY_API_KEY}" # Resolved from environment
STATIC_VALUE: "hardcoded" # Static valueEnvironment variables are resolved at runtime from:
- System environment
~/.dsagent/.envfile- Current directory
.envfile
Web search capability using Brave Search API.
dsagent mcp add brave-searchRequired: BRAVE_API_KEY - Get one at brave.com/search/api
Package: @modelcontextprotocol/server-brave-search
Tools provided:
brave_web_search- Search the web
Secure access to local file system.
dsagent mcp add filesystemRequired: Paths to allow access (prompted during setup)
Package: @modelcontextprotocol/server-filesystem
Tools provided:
read_file- Read file contentswrite_file- Write to fileslist_directory- List directory contentscreate_directory- Create directories
GitHub repository access for reading issues, PRs, code, etc.
dsagent mcp add githubRequired: GITHUB_TOKEN - Personal access token with repo scope
Package: @modelcontextprotocol/server-github
Tools provided:
search_repositories- Search GitHub reposget_file_contents- Read files from reposlist_issues- List repository issuescreate_issue- Create issues
Persistent memory/knowledge base for storing and retrieving information.
dsagent mcp add memoryRequired: None
Package: @modelcontextprotocol/server-memory
Tools provided:
store_memory- Store informationretrieve_memory- Retrieve stored information
Fetch and parse web content (HTML, JSON, etc.).
dsagent mcp add fetchRequired: None
Package: @modelcontextprotocol/server-fetch
Tools provided:
fetch- Fetch URL content
Google BigQuery database access using the official Google Toolbox.
dsagent mcp add bigqueryRequired:
- Path to Google Toolbox binary (prompted during setup)
BIGQUERY_PROJECT- Your GCP project ID
Download: Google MCP Toolbox
Tools provided:
- BigQuery SQL queries
- Table listing and schema inspection
- Data exploration
Manual configuration:
servers:
- name: bigquery
transport: stdio
command: ["/path/to/toolbox", "--prebuilt", "bigquery", "--stdio"]
env:
BIGQUERY_PROJECT: "your-project-id"from dsagent import ConversationalAgent, ConversationalAgentConfig
from pathlib import Path
config = ConversationalAgentConfig(
model="gpt-4o",
mcp_config=Path("~/.dsagent/mcp.yaml").expanduser(),
)
agent = ConversationalAgent(config)
agent.start()
# Agent can now use web search and other MCP tools
response = agent.chat("Search for the latest Python 3.13 features")
print(response.content)
agent.shutdown()from dsagent import PlannerAgent
agent = PlannerAgent(
model="gpt-4o",
mcp_config="~/.dsagent/mcp.yaml",
)
agent.start()
for event in agent.run_stream("Research current AI trends and summarize"):
if event.type == EventType.ANSWER_ACCEPTED:
print(event.message)
agent.shutdown()dsagent mcp listShows all configured servers with their status.
# From template
dsagent mcp add brave-search
# Templates available:
# - brave-search
# - filesystem
# - github
# - memory
# - fetchdsagent mcp remove brave_searchEdit ~/.dsagent/mcp.yaml directly for custom servers:
servers:
- name: my_custom_server
transport: stdio
command: ["python", "-m", "my_mcp_server"]
env:
MY_CONFIG: "value"You can connect to any MCP-compatible server:
For servers that communicate via stdin/stdout:
servers:
- name: my_server
transport: stdio
command: ["path/to/server", "--arg1", "value"]
env:
CONFIG_VAR: "value"For HTTP-based servers:
servers:
- name: my_http_server
transport: http
url: "http://localhost:8080/mcp"-
Check if the command is installed:
npx -y @modelcontextprotocol/server-brave-search --help
-
Check if Node.js/npx is available:
which npx
-
Check environment variables are set:
echo $BRAVE_API_KEY
-
Verify the server is configured:
dsagent mcp list
-
Check the MCP config path is correct:
dsagent --mcp-config ~/.dsagent/mcp.yaml
Ensure variables are in one of these locations:
- System environment:
export BRAVE_API_KEY="..." - User config:
~/.dsagent/.env - Project config:
./.env