# apify/apify-mcp-server architecture

> Architecture diagram of the GitHub repository apify/apify-mcp-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/apify/apify-mcp-server
- Repository: https://github.com/apify/apify-mcp-server

## Overview

Apify MCP Server exposes Apify Actors and platform operations to AI assistants through MCP. A client connects over Streamable HTTP or local stdio, discovers tools/resources/prompts, invokes a selected operation, and receives results from Apify. The graph separates tool discovery and execution from Actor search/run workflows, platform-management tools, and resource/widget surfaces; payment providers are an optional execution capability. README documents the product-level workflows; source-index references and sampled excerpts support selected internal links, but unsampled implementations are not claimed as inspected.

Main entry points: [`src/mcp/server.ts`](https://github.com/apify/apify-mcp-server/blob/master/src/mcp/server.ts) (MCP server), [`src/tools/actors/call_actor.ts`](https://github.com/apify/apify-mcp-server/blob/master/src/tools/actors/call_actor.ts) (Run Actor), [`src/mcp/tool_call_engine.ts`](https://github.com/apify/apify-mcp-server/blob/master/src/mcp/tool_call_engine.ts) (Tool call engine), [`src/resources/resource_service.ts`](https://github.com/apify/apify-mcp-server/blob/master/src/resources/resource_service.ts) (MCP resources)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_protocol["MCP interface"]
  node_server["MCP server<br/>[server.ts]"]
  node_stdio["stdio transport<br/>[stdio.ts]"]
end

subgraph group_tools["Tool discovery"]
  node_toolregistry["Tool registry<br/>[registry.ts]"]
  node_toolfactory["Actor tool factory"]
  node_search["Actor discovery<br/>[search_actors.ts]"]
end

subgraph group_execution["Actor execution"]
  node_callengine["Tool call engine"]
  node_dispatch["Tool dispatcher<br/>[tool_dispatch.ts]"]
  node_actorcall["Run Actor<br/>[call_actor.ts]"]
end

subgraph group_platform["Platform operations"]
  node_actoradmin["Actor management"]
  node_runs["Run management"]
  node_builds["Build management"]
  node_schedules["Schedules"]
  node_tasks["Actor tasks"]
  node_storage["Storage tools"]
end

subgraph group_support["Resources and payments"]
  node_resources["MCP resources"]
  node_apiresources["API resource proxy<br/>[api_resources.ts]"]
  node_widgets["Widget resources<br/>[widgets.ts]"]
  node_prompts["Prompt service<br/>[prompt_service.ts]"]
  node_payments["Payment providers"]
  node_client["Apify client<br/>[apify_client.ts]"]
end

node_assistant(("AI assistant"))
node_apify["Apify API"]

node_assistant -->|"connects via MCP"| node_server
node_assistant -->|"connects locally"| node_stdio
node_server -->|"loads tools"| node_toolregistry
node_server -->|"registers resources"| node_resources
node_server -->|"registers prompts"| node_prompts
node_toolregistry -->|"uses factory"| node_toolfactory
node_assistant -->|"discovers Actors"| node_search
node_search -->|"searches Store"| node_apify
node_server -->|"handles tool calls"| node_callengine
node_callengine -->|"dispatches call"| node_dispatch
node_callengine -->|"checks payment conflict"| node_actorcall
node_dispatch -->|"routes Actor call"| node_actorcall
node_actorcall -->|"runs Actor"| node_apify
node_actoradmin -->|"manages Actors"| node_apify
node_runs -->|"manages runs"| node_apify
node_builds -->|"manages builds"| node_apify
node_schedules -->|"manages schedules"| node_apify
node_tasks -->|"manages tasks"| node_apify
node_storage -->|"reads storage"| node_apify
node_resources -->|"reads API resources"| node_apiresources
node_resources -->|"serves widgets"| node_widgets
node_apiresources -->|"proxies API reads"| node_apify
node_actorcall -->|"uses client"| node_client
node_client -->|"sends API requests"| node_apify
node_payments -.->|"adds payment headers"| node_client
node_assistant -.->|"pays for runs"| node_payments

click node_server "https://github.com/apify/apify-mcp-server/blob/master/src/mcp/server.ts"
click node_stdio "https://github.com/apify/apify-mcp-server/blob/master/src/stdio.ts"
click node_toolregistry "https://github.com/apify/apify-mcp-server/blob/master/src/tools/registry.ts"
click node_toolfactory "https://github.com/apify/apify-mcp-server/blob/master/src/tools/actors/actor_tools_factory.ts"
click node_search "https://github.com/apify/apify-mcp-server/blob/master/src/tools/actors/search_actors.ts"
click node_callengine "https://github.com/apify/apify-mcp-server/blob/master/src/mcp/tool_call_engine.ts"
click node_dispatch "https://github.com/apify/apify-mcp-server/blob/master/src/mcp/tool_dispatch.ts"
click node_actorcall "https://github.com/apify/apify-mcp-server/blob/master/src/tools/actors/call_actor.ts"
click node_actoradmin "https://github.com/apify/apify-mcp-server/tree/master/src/tools/actors"
click node_runs "https://github.com/apify/apify-mcp-server/tree/master/src/tools/runs"
click node_builds "https://github.com/apify/apify-mcp-server/tree/master/src/tools/builds"
click node_schedules "https://github.com/apify/apify-mcp-server/tree/master/src/tools/schedules"
click node_tasks "https://github.com/apify/apify-mcp-server/tree/master/src/tools/tasks"
click node_storage "https://github.com/apify/apify-mcp-server/tree/master/src/tools/storage"
click node_resources "https://github.com/apify/apify-mcp-server/blob/master/src/resources/resource_service.ts"
click node_apiresources "https://github.com/apify/apify-mcp-server/blob/master/src/resources/api_resources.ts"
click node_widgets "https://github.com/apify/apify-mcp-server/blob/master/src/resources/widgets.ts"
click node_prompts "https://github.com/apify/apify-mcp-server/blob/master/src/prompts/prompt_service.ts"
click node_payments "https://github.com/apify/apify-mcp-server/tree/master/src/payments"
click node_client "https://github.com/apify/apify-mcp-server/blob/master/src/apify_client.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server,node_stdio toneBlue
class node_toolregistry,node_toolfactory,node_search toneAmber
class node_callengine,node_dispatch,node_actorcall,node_apify toneMint
class node_actoradmin,node_runs,node_builds,node_schedules,node_tasks,node_storage toneRose
class node_resources,node_apiresources,node_widgets,node_prompts,node_payments,node_client,node_assistant toneIndigo
```

## Components

### MCP interface

- [MCP server](https://github.com/apify/apify-mcp-server/blob/master/src/mcp/server.ts): `src/mcp/server.ts`
- [stdio transport](https://github.com/apify/apify-mcp-server/blob/master/src/stdio.ts): `src/stdio.ts`

### Tool discovery

- [Tool registry](https://github.com/apify/apify-mcp-server/blob/master/src/tools/registry.ts): `src/tools/registry.ts`
- [Actor tool factory](https://github.com/apify/apify-mcp-server/blob/master/src/tools/actors/actor_tools_factory.ts): `src/tools/actors/actor_tools_factory.ts`
- [Actor discovery](https://github.com/apify/apify-mcp-server/blob/master/src/tools/actors/search_actors.ts): `src/tools/actors/search_actors.ts`

### Actor execution

- [Tool call engine](https://github.com/apify/apify-mcp-server/blob/master/src/mcp/tool_call_engine.ts): `src/mcp/tool_call_engine.ts`
- [Tool dispatcher](https://github.com/apify/apify-mcp-server/blob/master/src/mcp/tool_dispatch.ts): `src/mcp/tool_dispatch.ts`
- [Run Actor](https://github.com/apify/apify-mcp-server/blob/master/src/tools/actors/call_actor.ts): `src/tools/actors/call_actor.ts`

### Platform operations

- [Actor management](https://github.com/apify/apify-mcp-server/tree/master/src/tools/actors): `src/tools/actors`
- [Run management](https://github.com/apify/apify-mcp-server/tree/master/src/tools/runs): `src/tools/runs`
- [Build management](https://github.com/apify/apify-mcp-server/tree/master/src/tools/builds): `src/tools/builds`
- [Schedules](https://github.com/apify/apify-mcp-server/tree/master/src/tools/schedules): `src/tools/schedules`
- [Actor tasks](https://github.com/apify/apify-mcp-server/tree/master/src/tools/tasks): `src/tools/tasks`
- [Storage tools](https://github.com/apify/apify-mcp-server/tree/master/src/tools/storage): `src/tools/storage`

### Resources and payments

- [MCP resources](https://github.com/apify/apify-mcp-server/blob/master/src/resources/resource_service.ts): `src/resources/resource_service.ts`
- [API resource proxy](https://github.com/apify/apify-mcp-server/blob/master/src/resources/api_resources.ts): `src/resources/api_resources.ts`
- [Widget resources](https://github.com/apify/apify-mcp-server/blob/master/src/resources/widgets.ts): `src/resources/widgets.ts`
- [Prompt service](https://github.com/apify/apify-mcp-server/blob/master/src/prompts/prompt_service.ts): `src/prompts/prompt_service.ts`
- [Payment providers](https://github.com/apify/apify-mcp-server/tree/master/src/payments): `src/payments`
- [Apify client](https://github.com/apify/apify-mcp-server/blob/master/src/apify_client.ts): `src/apify_client.ts`

### Other components

- **AI assistant**
- **Apify API**

## Connections

- AI assistant → MCP server: connects via MCP (evidence: `README.md`)
- AI assistant → stdio transport: connects locally (evidence: `README.md`)
- MCP server → Tool registry: loads tools (evidence: `src/mcp/server.ts`)
- MCP server → MCP resources: registers resources (evidence: `src/mcp/server.ts`)
- MCP server → Prompt service: registers prompts (evidence: `src/mcp/server.ts`)
- Tool registry → Actor tool factory: uses factory (evidence: `src/tools/index.ts`)
- AI assistant → Actor discovery: discovers Actors (evidence: `README.md`)
- Actor discovery → Apify API: searches Store (evidence: `README.md`)
- MCP server → Tool call engine: handles tool calls (evidence: `src/mcp/server.ts`)
- Tool call engine → Tool dispatcher: dispatches call (evidence: `src/mcp/tool_call_engine.ts`)
- Tool call engine → Run Actor: checks payment conflict (evidence: `src/mcp/tool_call_engine.ts`)
- Tool dispatcher → Run Actor: routes Actor call
- Run Actor → Apify API: runs Actor (evidence: `README.md`)
- Actor management → Apify API: manages Actors (evidence: `README.md`)
- Run management → Apify API: manages runs (evidence: `README.md`)
- Build management → Apify API: manages builds
- Schedules → Apify API: manages schedules
- Actor tasks → Apify API: manages tasks
- Storage tools → Apify API: reads storage (evidence: `README.md`)
- MCP resources → API resource proxy: reads API resources (evidence: `src/resources/resource_service.ts`)
- MCP resources → Widget resources: serves widgets (evidence: `src/resources/resource_service.ts`)
- API resource proxy → Apify API: proxies API reads (evidence: `src/resources/api_resources.ts`)
- Run Actor → Apify client: uses client (evidence: `src/mcp/tool_call_engine.ts`)
- Apify client → Apify API: sends API requests (evidence: `src/apify_client.ts`)
- Payment providers → Apify client: adds payment headers (evidence: `src/apify_client.ts`)
- AI assistant → Payment providers: pays for runs (evidence: `README.md`)
