Skip to main content

MCP Integration

The Model Context Protocol (MCP) provides a standardized way to give Claude access to external tools and data sources.

What is MCP?

MCP is an open protocol that lets you connect Claude to:
  • Databases — Query and update data
  • APIs — Call external services
  • File systems — Read and write files
  • Custom tools — Any functionality you define

MCP vs Built-in Tools

Using MCP in Castari Agents

1. Install MCP SDK

2. Define MCP Tools

3. Connect to Claude

Example: Database Agent

A complete example integrating with PostgreSQL:
Set the secret:

Example: API Integration

Integrating with an external REST API:

Best Practices

Security

  1. Validate inputs — Never pass raw user input to databases or APIs
  2. Limit scope — Only expose necessary operations
  3. Use secrets — Never hardcode credentials

Performance

  1. Connection pooling — Reuse database connections
  2. Timeouts — Set reasonable timeouts for external calls
  3. Caching — Cache frequently accessed data

Error Handling

See Also

Custom Agents

Building agents from scratch

Secrets

Managing credentials