Skip to content

MCP Tools

SandBase provides 2000+ pre-built tools via the Model Context Protocol (MCP) that you can attach to your agents. Tools give agents the ability to interact with the real world — search the web, query databases, send emails, and more.

How It Works

User Message → Agent (LLM) → Tool Call Decision


                            ┌───────────────┐
                            │  MCP Server   │
                            │  (tool host)  │
                            └───────┬───────┘


                            Tool Execution


                            Result → Agent → Response

The agent's LLM decides when to call tools based on the user's request. SandBase handles the MCP protocol, tool execution, and result formatting automatically.

Attaching Tools to Agents

Using Platform Tools

SandBase hosts popular MCP servers that you can attach by name:

python
agent = requests.post(
    "https://api.sandbase.ai/default/v1/agents",
    headers={"Authorization": "Bearer sk-sb-YOUR_KEY"},
    json={
        "name": "Research Agent",
        "model": {"name": "claude-sonnet-4"},
        "system": "You are a research assistant. Use tools to find information.",
        "tools": [
            {"type": "mcp", "server": "web-search"},
            {"type": "mcp", "server": "web-fetch"},
            {"type": "mcp", "server": "wikipedia"},
        ]
    }
).json()

Using Custom MCP Servers

Connect your own MCP servers:

python
agent = requests.post(
    "https://api.sandbase.ai/default/v1/agents",
    headers={"Authorization": "Bearer sk-sb-YOUR_KEY"},
    json={
        "name": "Data Agent",
        "model": {"name": "gpt-4o"},
        "system": "You help users query their database.",
        "mcp_servers": [
            {
                "name": "my-database",
                "url": "https://your-server.com/mcp",
                "headers": {"X-API-Key": "your-key"}
            }
        ]
    }
).json()

Available Tool Categories

Tool ServerToolsDescription
web-searchsearchSearch the web via multiple engines
web-fetchfetch, screenshotFetch web pages, take screenshots
browsernavigate, click, type, screenshotFull browser automation (Playwright-based)
wikipediasearch, get_articleWikipedia search and retrieval
arxivsearch, get_paperAcademic paper search
newssearch, trendingReal-time news aggregation

Browser Automation

Tool ServerToolsDescription
browsernavigate, click, type, screenshot, scroll, waitFull headless browser control
scraperextract, crawl, parseStructured data extraction from web pages
pdf-readerextract_text, extract_tablesParse PDF documents from URLs

Data & Databases

Tool ServerToolsDescription
postgresquery, list_tables, describe, explainPostgreSQL database access
mysqlquery, list_tables, describeMySQL database access
redisget, set, del, keys, hget, hsetRedis key-value and hash operations
sqlitequery, execute, list_tablesSQLite file-based database
mongodbfind, insert, update, aggregateMongoDB document operations
elasticsearchsearch, index, bulkElasticsearch full-text search
supabasequery, insert, rpcSupabase Postgres + realtime

Code Execution

Tool ServerToolsDescription
code-execrun_python, run_javascript, run_typescriptExecute code snippets in sandboxed environments
jupyterexecute_cell, create_notebookJupyter notebook operations
shellexec, background, killShell command execution
dockerrun, build, logsDocker container management

Version Control & DevOps

Tool ServerToolsDescription
githubsearch_repos, get_file, create_issue, create_pr, list_commitsGitHub API integration
gitlabsearch, get_file, create_issue, create_mrGitLab API integration
gitclone, diff, commit, log, branchGit operations
jirasearch, create_issue, update_issue, transitionJira project management
linearcreate_issue, search, updateLinear issue tracking

Communication

Tool ServerToolsDescription
emailsend, search, read, replyEmail operations (SMTP/IMAP)
slacksend_message, search, list_channels, reactSlack workspace integration
discordsend_message, read_messages, reactDiscord bot operations
twiliosend_sms, make_callSMS and voice via Twilio
telegramsend_message, get_updatesTelegram bot API
webhooksend, registerGeneric webhook dispatch

File & Storage

Tool ServerToolsDescription
filesystemread, write, list, delete, move, copyLocal file operations
s3get, put, list, delete, presignAWS S3 operations
google-drivesearch, download, upload, shareGoogle Drive access
dropboxupload, download, list, shareDropbox file storage
gcsget, put, list, deleteGoogle Cloud Storage

AI & Generation

Tool ServerToolsDescription
image-gengenerate, edit, variationsAI image generation (DALL-E, Stable Diffusion)
ttssynthesize, list_voicesText-to-speech synthesis
transcriptiontranscribe, translateAudio transcription and translation
embeddingsembed, similarityVector embeddings and similarity search
ocrextract_text, extract_structuredOptical character recognition

Analytics & Monitoring

Tool ServerToolsDescription
google-analyticsquery, reportGA4 data retrieval
posthogquery, captureProduct analytics
sentrylist_issues, get_issue, resolveError tracking
datadogquery_metrics, list_alertsInfrastructure monitoring

CRM & Business

Tool ServerToolsDescription
hubspotsearch_contacts, create_deal, updateHubSpot CRM
salesforcequery, create, updateSalesforce SOQL and CRUD
notionsearch, create_page, update_page, query_databaseNotion workspace
airtablelist_records, create, updateAirtable base operations

Listing Available Tools

List All MCP Servers

bash
curl https://api.sandbase.ai/api/mcp/servers \
  -H "Authorization: Bearer sk-sb-YOUR_KEY"

List Tools for a Server

bash
curl https://api.sandbase.ai/api/mcp/web-search/tools \
  -H "Authorization: Bearer sk-sb-YOUR_KEY"

Response:

json
{
  "tools": [
    {
      "name": "search",
      "description": "Search the web for information",
      "inputSchema": {
        "type": "object",
        "properties": {
          "query": {"type": "string", "description": "Search query"},
          "limit": {"type": "integer", "default": 10}
        },
        "required": ["query"]
      }
    }
  ]
}

Tool Execution Flow

When an agent uses a tool, the flow is:

  1. User sends message → Agent receives it
  2. Agent decides → LLM outputs a tool call (based on system prompt + available tools)
  3. SandBase executes → Calls the MCP server, gets the result
  4. Agent continues → LLM receives tool result, generates final response
python
# This happens automatically — you just send messages
response = requests.post(
    f"https://api.sandbase.ai/default/v1/sessions/{session_id}/events",
    headers={"Authorization": "Bearer sk-sb-YOUR_KEY"},
    json={
        "type": "message",
        "role": "user",
        "content": "What's the weather in Tokyo today?"
    }
).json()

# Agent automatically called web-search, then responded
print(response["content"])
# "Based on my search, Tokyo is currently 22°C with partly cloudy skies..."

Custom Server Setup Guide

Beyond the 2000+ platform tools, you can connect your own MCP servers to give agents access to proprietary APIs, internal databases, or custom logic.

Self-Hosted Server Requirements

Your MCP server must:

  • Implement the MCP specification (SSE transport)
  • Be accessible via HTTPS from SandBase's infrastructure
  • Respond to tools/list and tools/call methods
  • Return results within 30 seconds (configurable timeout)

Connecting a Custom Server

python
import requests

agent = requests.post(
    "https://api.sandbase.ai/default/v1/agents",
    headers={"Authorization": "Bearer sk-sb-YOUR_KEY"},
    json={
        "name": "Internal Data Agent",
        "model": {"name": "claude-sonnet-4"},
        "system": "You help employees query internal systems.",
        "mcp_servers": [
            {
                "name": "internal-crm",
                "url": "https://mcp.yourcompany.com/crm",
                "headers": {
                    "Authorization": "Bearer your-internal-token",
                    "X-Team-ID": "engineering"
                },
                "timeout": 15000
            }
        ]
    }
).json()

Authentication Options

SandBase supports several authentication methods for custom servers:

MethodConfigurationUse Case
Bearer token"Authorization": "Bearer <token>"Most APIs
API key header"X-API-Key": "<key>"Simple key auth
Custom headersAny header key-value pairsInternal services
mTLS"tls": {"cert": "...", "key": "..."}Zero-trust environments
python
# Bearer token authentication
{
    "name": "my-server",
    "url": "https://mcp.example.com",
    "headers": {"Authorization": "Bearer sk-your-token"}
}

# API key authentication
{
    "name": "my-server",
    "url": "https://mcp.example.com",
    "headers": {"X-API-Key": "your-api-key"}
}

# Multiple custom headers
{
    "name": "my-server",
    "url": "https://mcp.internal.corp",
    "headers": {
        "X-API-Key": "key-123",
        "X-Org-ID": "org-456",
        "X-Environment": "production"
    }
}

Server Configuration Options

OptionTypeDefaultDescription
namestringrequiredUnique identifier for the server
urlstringrequiredHTTPS endpoint of your MCP server
headersobject{}Authentication and custom headers
timeoutinteger30000Request timeout in milliseconds
retryobject{"attempts": 2, "backoff": 1000}Retry configuration
tools_filterarrayall toolsSubset of tools to expose to the agent

Filtering Tools from a Server

If your MCP server exposes many tools but you only want the agent to use a few:

python
{
    "name": "internal-platform",
    "url": "https://mcp.yourcompany.com/platform",
    "headers": {"Authorization": "Bearer token"},
    "tools_filter": ["get_user", "search_tickets", "create_ticket"]
}

Health Checks and Monitoring

SandBase pings custom servers periodically. If a server is unreachable, tool calls will fail gracefully and the agent will inform the user.

Check server connectivity:

bash
curl https://api.sandbase.ai/api/mcp/custom/internal-crm/health \
  -H "Authorization: Bearer sk-sb-YOUR_KEY"
json
{
  "status": "healthy",
  "latency_ms": 45,
  "tools_count": 8,
  "last_checked": "2025-01-15T10:30:00Z"
}

Building Your Own MCP Server

A minimal MCP server in Python using the official SDK:

python
from mcp.server import Server
from mcp.types import Tool, TextContent

server = Server("my-custom-tools")

@server.list_tools()
async def list_tools():
    return [
        Tool(
            name="lookup_customer",
            description="Look up a customer by email or ID",
            inputSchema={
                "type": "object",
                "properties": {
                    "query": {"type": "string", "description": "Email or customer ID"}
                },
                "required": ["query"]
            }
        )
    ]

@server.call_tool()
async def call_tool(name: str, arguments: dict):
    if name == "lookup_customer":
        customer = await db.find_customer(arguments["query"])
        return [TextContent(type="text", text=json.dumps(customer))]

# Run with SSE transport for SandBase compatibility
if __name__ == "__main__":
    from mcp.server.sse import SseServerTransport
    from starlette.applications import Starlette
    from starlette.routing import Route

    sse = SseServerTransport("/messages")
    app = Starlette(routes=[
        Route("/sse", endpoint=sse.handle_sse),
        Route("/messages", endpoint=sse.handle_post_message, methods=["POST"]),
    ])
    # Deploy with: uvicorn server:app --host 0.0.0.0 --port 8080

Tool Selection Best Practices

Choosing the right tools for your agent impacts performance, cost, and reliability.

Match Tools to Agent Purpose

Define your agent's role first, then select only the tools it needs:

Agent TypeRecommended ToolsWhy
Research assistantweb-search, web-fetch, wikipediaNeeds information retrieval
Data analystpostgres, code-exec, filesystemNeeds data access and computation
Customer supportnotion, email, slackNeeds knowledge base and communication
DevOps botgithub, shell, docker, sentryNeeds code and infrastructure access
Content creatorweb-search, image-gen, filesystemNeeds research and asset creation

The 3-5 Tool Rule

Agents perform best with 3-5 focused tools. Each additional tool:

  • Adds ~200-500 tokens to the context (tool descriptions)
  • Increases decision complexity for the LLM
  • Raises the chance of incorrect tool selection
python
# ✅ Good — focused tool set for a research agent
tools = [
    {"type": "mcp", "server": "web-search"},
    {"type": "mcp", "server": "web-fetch"},
    {"type": "mcp", "server": "wikipedia"},
]

# ❌ Bad — too many tools, agent gets confused
tools = [
    {"type": "mcp", "server": "web-search"},
    {"type": "mcp", "server": "postgres"},
    {"type": "mcp", "server": "github"},
    {"type": "mcp", "server": "email"},
    {"type": "mcp", "server": "slack"},
    {"type": "mcp", "server": "s3"},
    {"type": "mcp", "server": "docker"},
    # ... agent doesn't know which to use
]

Guide Tool Usage in System Prompts

Tell the agent when and how to use each tool:

python
system = """You are a research assistant.

TOOL USAGE GUIDELINES:
- Use web-search for current events, recent data, and factual questions
- Use wikipedia for historical context and encyclopedic information
- Use web-fetch to read full articles when search snippets aren't enough
- Always cite your sources with URLs
- If a search returns no results, tell the user honestly
- Never make up information — if you can't verify something, say so
"""

Handle Tool Errors Gracefully

Tools can fail (network issues, rate limits, server downtime). Configure your agent to handle failures:

python
system = """...
ERROR HANDLING:
- If a tool call fails, explain the issue to the user and suggest alternatives
- If web-search is unavailable, try wikipedia as a fallback
- Never retry a failed tool more than once in the same turn
- If all tools fail, provide your best answer from training data with a disclaimer
"""

Use Tool Filters for Security

When connecting to servers with broad access, restrict which tools the agent can use:

python
# Only expose read operations, not write
{
    "name": "production-db",
    "url": "https://mcp.internal.com/postgres",
    "headers": {"Authorization": "Bearer read-only-token"},
    "tools_filter": ["query", "list_tables", "describe"]
    # Excludes: execute, drop_table, alter, etc.
}

Cost Optimization

StrategyImpactHow
Fewer toolsLower token costRemove tools the agent rarely uses
Specific system promptsFewer unnecessary callsTell agent exactly when to use each tool
Tool filtersReduced schema sizeOnly expose needed operations
CachingLower latency + costPlatform caches repeated tool calls

Browse All Tools

Explore the full catalog of 2000+ tools at sandbase.ai/plugins.

Next Steps