# MCP Tools

> Connect 50+ integrations, databases, media providers, and custom APIs to your agents using the Model Context Protocol (MCP).

Source: https://0.0.0.0:8080/docs/mcp-tools

PromptRails provides first-class support for the **Model Context Protocol (MCP)**, enabling your agents to invoke external tools, query databases, generate media, and connect to 50+ third-party services.

## What is MCP?

The Model Context Protocol is an open standard for connecting LLMs to external tools and data sources. MCP defines how tools are discovered, described, and invoked, creating a uniform interface between AI agents and the services they interact with.

In PromptRails, MCP tools are workspace-scoped resources that can be attached to any agent. When an LLM decides to use a tool during execution, PromptRails handles the invocation, parameter validation, and result formatting.

## Tool Types

PromptRails supports six types of MCP tools:

### Integration Tools (`integration`)

Integration tools connect to 27+ third-party services through the PromptRails integration service. Each integration provides a set of pre-built tools discovered via the MCP protocol.

**Supported integrations:**

| Category             | Services                                                           |
| -------------------- | ------------------------------------------------------------------ |
| **Google**           | Analytics, Search Console, Ads, Drive, Docs, Sheets, Slides, Gmail |
| **CRM**              | HubSpot, Salesforce, Pipedrive                                     |
| **Lead Generation**  | Apollo.io                                                          |
| **Accounting**       | Stripe, Xero, QuickBooks                                           |
| **Issue Management** | Jira, Confluence, Linear, Trello, Notion                           |
| **Development**      | Sentry, Figma, Supabase, GitHub                                    |
| **Communication**    | Slack, Telegram, Resend                                            |

Integration tools are installed from the **MCP Template Marketplace**. Each template handles credential setup, tool discovery, and configuration automatically.

Google integrations support both **OAuth2** and **Service Account** authentication, including domain-wide delegation with user impersonation.

### Data Source Tools (`datasource`)

Data source tools execute SQL queries against connected databases. They support dynamic queries — the agent writes the SQL at runtime.

**Supported databases:** PostgreSQL, MySQL, BigQuery, Snowflake, Redshift, MSSQL, ClickHouse

Install database tools from the template marketplace by selecting an existing database credential. The tool provides three actions:

- **query** — Execute SQL queries
- **list_tables** — List all tables in the database
- **describe_table** — Get column details for a table

### Media Tools (`media`)

Media tools generate speech, images, and video through AI providers.

| Category             | Providers                           |
| -------------------- | ----------------------------------- |
| **Text to Speech**   | ElevenLabs, Deepgram                |
| **Speech to Text**   | Deepgram                            |
| **Image Generation** | Fal (FLUX), Replicate, Stability AI |
| **Video Generation** | Runway, Pika, Luma Dream Machine    |

Media tools use workspace-level credentials configured in Settings > Credentials.

### API Tools (`api`)

API tools make HTTP requests to external REST APIs. You define the endpoint, method, headers, and parameter mapping.

### Built-in Tools (`builtin`)

Built-in tools provide predefined functionality that runs within the PromptRails platform:

- **State Manager** — Store and retrieve key-value state during agent execution
- **Math Calculator** — Perform mathematical calculations
- **Date & Time** — Get current date and time in UTC

### Remote MCP Tools (`remote_mcp`)

Remote MCP tools connect to external MCP servers that implement the full MCP protocol. This allows you to use tools from any MCP-compatible server.

## MCP Template Marketplace

The template marketplace provides one-click installation for all supported integrations. Each template includes:

- Pre-configured tool definitions
- Credential setup with parameter validation
- Setup instructions for the service
- Automatic tool discovery

**To install a template:**

1. Go to **MCP Templates** in your workspace
2. Find the integration you want
3. Enter the required credentials (API key, OAuth tokens, or Service Account)
4. Click **Install**

The tool is created with all discovered sub-tools (e.g., installing HubSpot gives you `hubspot_search_contacts`, `hubspot_create_deal`, etc.).

## Tool Schema

Each tool defines a JSON schema describing its parameters. This schema is provided to the LLM so it understands what parameters are available:

```json
{
  "type": "object",
  "properties": {
    "query": {
      "type": "string",
      "description": "The search query"
    },
    "max_results": {
      "type": "integer",
      "description": "Maximum number of results",
      "default": 10
    }
  },
  "required": ["query"]
}
```

## Adding Tools to Agents

Tools are linked to agents through the agent version configuration in the UI or API. Any tool type can be attached to any agent type.

## Tool Discovery

For integration and remote MCP tools, PromptRails discovers available sub-tools from the service. You can view and test discovered tools on the tool detail page under the **Test** tab.

## Tool Status

| Status     | Description                         |
| ---------- | ----------------------------------- |
| `active`   | Tool is available for use           |
| `inactive` | Tool is disabled but not removed    |
| `error`    | Tool encountered a connection error |
| `archived` | Tool is permanently disabled        |

## Tool Invocation Flow

When an agent executes and the LLM decides to call a tool:

1. The LLM generates a tool call with parameters
2. PromptRails validates the parameters against the tool schema
3. The tool is invoked (API call, database query, MCP request, etc.)
4. Results are returned to the LLM for incorporation into the response
5. The entire tool call is recorded as an `mcp_call` trace span

## Related Topics

- [Integrations](/integrations) — Browse all 50+ supported integrations
- [Agents](/docs/agents) — Attaching tools to agents
- [Credentials](/docs/credentials) — Authentication for tool endpoints
- [MCP Server](/docs/mcp-server) — PromptRails as an MCP server for IDEs
- [Tracing](/docs/tracing) — Tool calls appear as `tool` and `mcp_call` spans
