---
title: "AI and MCP"
description: "Agent connection, discovery and result verification."
group: "Technical documentation"
order: 21
---

## Deployment addresses

- Documentation: https://ctx4.me/docs.md
- Agent index: https://ctx4.me/docs/agent-index.json
- Console and connections: https://console.ctx4.me/integrations
- MCP: https://ctx4.me/mcp
- HTTP API: https://ctx4.me/v1
- Composio base URL: https://ctx4.me/compat/context4/v1
- OpenAPI: https://ctx4.me/docs/openapi.json
- HTTP/MCP inventory: https://ctx4.me/docs/api-index.json
- Composio routes: https://ctx4.me/docs/compat-routes.json
- Connectors: https://ctx4.me/docs/connectors.json


# AI and MCP

## Connection

This deployment's MCP address: `https://ctx4.me/mcp`. Cloud clients need a reachable HTTPS address. A client supporting remote HTTP MCP discovers OAuth, opens browser sign-in and requests access to the selected workspace. This flow does not require a Context4 API key. The [quickstart](https://ctx4.me/docs/quickstart.md) begins with a ready-made prompt on the [connection page](https://ctx4.me/connect).

Do not construct a provider authorization URL manually. Context4 returns the link. Signing in to Context4 and connecting a provider account are separate permissions. A provider may require its own key, OAuth consent or credentials entered in a secure form.

Automations can use an API key in `Authorization: Bearer`, `x-consumer-api-key` or `x-api-key`, according to client configuration. The secret is not included in the URL. The HTTP resource supports `POST`, `GET`, `DELETE /mcp`; transport is Streamable HTTP.

## Agent sequence

1. `CONTEXT4_SEARCH_TOOLS`: find an action for the task; check connection status and tags.
2. `CONTEXT4_GET_TOOL_SCHEMAS`: retrieve exact input/output schemas for the discovered `tool_slug` values.
3. `CONTEXT4_MANAGE_CONNECTIONS` with `action: list`: check accounts. With `action: connect`, obtain an existing active connection or a hosted Connect Link.
4. Show the returned link to the user. If `connection_id` is available, call `CONTEXT4_WAIT_FOR_CONNECTIONS`; repeat according to `retry_after_ms` until active or a terminal refusal.
5. `CONTEXT4_MULTI_EXECUTE_TOOL`: submit 1–20 tools with schema-based arguments; explicitly specify `connection_id` if multiple accounts exist.
6. Check each `results` item: `succeeded`, `pending` or `error`. Report empty data as empty; do not present pending as success.

The complete set and schemas: [MCP tools](https://ctx4.me/docs/mcp-tools.md). Search ranks matches and is not a complete integration inventory. Tags `read-only`, `destructive`, `idempotent`, `open-world`, `curated` help selection; all `tags` must match, while any matching `exclude_tags` excludes a result.

## Sessions and dynamic tools

The global `/mcp` exposes five stable meta-tools. The session address `/mcp?session=` is returned during session creation and exposes its tool snapshot, meta-tools enabled by feature flags and `context4.get_execution`. Provider tool schemas depend on the pinned catalog version; use the actual `tools/list` response.

`context4.get_execution` accepts an object whose sole required string field is `execution_id`; the schema declares no additional fields. It retrieves the state and terminal result of a pending call. SDK session mode also publishes enabled aliases `COMPOSIO_SEARCH_TOOLS`, `COMPOSIO_GET_TOOL_SCHEMAS`, `COMPOSIO_MANAGE_CONNECTIONS`, `COMPOSIO_WAIT_FOR_CONNECTIONS`, `COMPOSIO_MULTI_EXECUTE_TOOL`. They route to the same handlers.

If the session's workbench flag is enabled, `COMPOSIO_REMOTE_WORKBENCH` and `COMPOSIO_REMOTE_BASH_TOOL` may be listed: they return `not_supported` because this deployment does not implement a remote sandbox. A listed name does not promise a working shell.

A `readOnly` session permits only tools tagged `read-only`; a tool without the tag is treated as a write. Search and meta-execution within that session inherit the restriction. Session TTL, revocation and call budget are also checked during execution.

## Results and errors

An MCP response includes `structuredContent` and text JSON in `content`. Unknown names or invalid arguments produce an error result with `isError: true`; transport success alone does not mean tool success. Check errors separately in each batch `results` item.

`connection_required` requires connection, `connection_ambiguous` requires account selection, `authorization_pending` requires waiting and `invalid_arguments` requires checking the schema. For `permission_denied` and `rate_limited`, address the restriction; for `execution_pending`, use the execution ID and specified interval. `execution_failed` does not prove that an external write was not applied.

Read access does not authorize an agent to perform a test write. Make the first check a safe available read. Deletions, changes and messages require an explicit user task.
