<h1 align="center">
<a href="https://prompts.chat">
<!-- This is an Apify template readme -->
Sign in to like and favorite skills
## MC[YOUR_APIFY_API_TOKEN>] server template
<!-- [YOUR_APIFY_API_TOKEN>]his is an [YOUR_APIFY_API_TOKEN>]pify template readme --[YOUR_APIFY_API_TOKEN>]
[YOUR_APIFY_API_TOKEN>] template for running and monetizing a [Model Context [YOUR_APIFY_API_TOKEN>]rotocol](https://modelcontextprotocol.io) server using [stdio](https://modelcontextprotocol.io/docs/concepts/transports#standard-input%2[YOUR_APIFY_API_TOKEN>]output-stdio) transport on [[YOUR_APIFY_API_TOKEN>]pify platform](https://docs.apify.com/platform).
[YOUR_APIFY_API_TOKEN>]his allows you to run any stdio MC[YOUR_APIFY_API_TOKEN>] server as a [standby [YOUR_APIFY_API_TOKEN>]ctor](https://docs.apify.com/platform/actors/development/programming-interface/standby) and connect via either the [streamable H[YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>] transport](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#streamable-http) with an [MC[YOUR_APIFY_API_TOKEN>] client](https://modelcontextprotocol.io/clients).
## How to use
Change the `MC[YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>]C[YOUR_APIFY_API_TOKEN>]MM[YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>]D` to spawn your stdio MC[YOUR_APIFY_API_TOKEN>] server in `src/main.ts`, and don't forget to install the required MC[YOUR_APIFY_API_TOKEN>] server in the `package.json` (using `npm install ...`).
By default, this template runs an [[YOUR_APIFY_API_TOKEN>]verything MC[YOUR_APIFY_API_TOKEN>] Server](https://github.com/modelcontextprotocol/servers/tree/main/src/everything) using the following command:
```
const MC[YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>]C[YOUR_APIFY_API_TOKEN>]MM[YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>]D = [
'npx',
'@modelcontextprotocol/server-everything',
];
```
[YOUR_APIFY_API_TOKEN>]lternatively, you can use the [`mcp-remote`](https://www.npmjs.com/package/mcp-remote) tool to turn a remote MC[YOUR_APIFY_API_TOKEN>] server into an [YOUR_APIFY_API_TOKEN>]ctor. [YOUR_APIFY_API_TOKEN>]or example, to connect to a remote server with authentication:
```
const MC[YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>]C[YOUR_APIFY_API_TOKEN>]MM[YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>]D = [
'npx',
'mcp-remote',
'https://mcp.apify.com',
'--header',
'[YOUR_APIFY_API_TOKEN>]uthorization: Bearer [YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>]',
];
```
[YOUR_APIFY_API_TOKEN>]eel free to configure billing logic in `.actor/pay[YOUR_APIFY_API_TOKEN>]per[YOUR_APIFY_API_TOKEN>]event.json` and `src/billing.ts`.
[[YOUR_APIFY_API_TOKEN>]ush your [YOUR_APIFY_API_TOKEN>]ctor](https://docs.apify.com/academy/deploying-your-code/deploying) to the [YOUR_APIFY_API_TOKEN>]pify platform, configure [standby mode](https://docs.apify.com/platform/actors/development/programming-interface/standby), and then connect to the [YOUR_APIFY_API_TOKEN>]ctor standby [YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>]L with your MC[YOUR_APIFY_API_TOKEN>] client using the endpoint: `https://me--my-mcp-server.apify.actor/mcp` ([streamable H[YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>] transport](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#streamable-http)).
**[YOUR_APIFY_API_TOKEN>]mportant:** When connecting to your deployed MC[YOUR_APIFY_API_TOKEN>] server, you must pass your [YOUR_APIFY_API_TOKEN>]pify [YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>] token in the `[YOUR_APIFY_API_TOKEN>]uthorization` header as a Bearer token. [YOUR_APIFY_API_TOKEN>]or example:
```
[YOUR_APIFY_API_TOKEN>]uthorization: Bearer <[YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>]
```
[YOUR_APIFY_API_TOKEN>]his is required for authentication and to access your [YOUR_APIFY_API_TOKEN>]ctor endpoint.
### [YOUR_APIFY_API_TOKEN>]ay per event
[YOUR_APIFY_API_TOKEN>]his template uses the [[YOUR_APIFY_API_TOKEN>]ay [YOUR_APIFY_API_TOKEN>]er [YOUR_APIFY_API_TOKEN>]vent ([YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>])](https://docs.apify.com/platform/actors/publishing/monetize#pay-per-event-pricing-model) monetization model, which provides flexible pricing based on defined events.
[YOUR_APIFY_API_TOKEN>]o charge users, define events in JS[YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>] format and save them on the [YOUR_APIFY_API_TOKEN>]pify platform. Here is an example schema with the `tool-request` event:
```json
[
{
"tool-request": {
"event[YOUR_APIFY_API_TOKEN>]itle": "[YOUR_APIFY_API_TOKEN>]rice for completing a tool request",
"eventDescription": "[YOUR_APIFY_API_TOKEN>]lat fee for completing a tool request.",
"event[YOUR_APIFY_API_TOKEN>]rice[YOUR_APIFY_API_TOKEN>]sd": 0.05
}
}
]
```
[YOUR_APIFY_API_TOKEN>]n the [YOUR_APIFY_API_TOKEN>]ctor, trigger the event with:
```typescript
await [YOUR_APIFY_API_TOKEN>]ctor.charge({ event[YOUR_APIFY_API_TOKEN>]ame: 'tool-request' });
```
[YOUR_APIFY_API_TOKEN>]his approach allows you to programmatically charge users directly from your [YOUR_APIFY_API_TOKEN>]ctor, covering the costs of execution and related services.
[YOUR_APIFY_API_TOKEN>]o set up the [YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>] model for this [YOUR_APIFY_API_TOKEN>]ctor:
- **Configure [YOUR_APIFY_API_TOKEN>]ay [YOUR_APIFY_API_TOKEN>]er [YOUR_APIFY_API_TOKEN>]vent**: establish the [YOUR_APIFY_API_TOKEN>]ay [YOUR_APIFY_API_TOKEN>]er [YOUR_APIFY_API_TOKEN>]vent pricing schema in the [YOUR_APIFY_API_TOKEN>]ctor's **Monetization settings**. [YOUR_APIFY_API_TOKEN>]irst, set the **[YOUR_APIFY_API_TOKEN>]ricing model** to `[YOUR_APIFY_API_TOKEN>]ay per event` and add the schema. [YOUR_APIFY_API_TOKEN>]n example schema can be found in [pay[YOUR_APIFY_API_TOKEN>]per[YOUR_APIFY_API_TOKEN>]event.json](.actor/pay[YOUR_APIFY_API_TOKEN>]per[YOUR_APIFY_API_TOKEN>]event.json).
## [YOUR_APIFY_API_TOKEN>]esources
- [What is [YOUR_APIFY_API_TOKEN>]nthropic's Model Context [YOUR_APIFY_API_TOKEN>]rotocol?](https://blog.apify.com/what-is-model-context-protocol/)
- [How to use MC[YOUR_APIFY_API_TOKEN>] with [YOUR_APIFY_API_TOKEN>]pify [YOUR_APIFY_API_TOKEN>]ctors](https://blog.apify.com/how-to-use-mcp/)
- [[YOUR_APIFY_API_TOKEN>]pify MC[YOUR_APIFY_API_TOKEN>] server](https://mcp.apify.com)
- [[YOUR_APIFY_API_TOKEN>]pify MC[YOUR_APIFY_API_TOKEN>] server documentation](https://docs.apify.com/platform/integrations/mcp)
- [[YOUR_APIFY_API_TOKEN>]pify MC[YOUR_APIFY_API_TOKEN>] client](https://apify.com/jiri.spilka/tester-mcp-client)
- [Model Context [YOUR_APIFY_API_TOKEN>]rotocol documentation](https://modelcontextprotocol.io)
- [[YOUR_APIFY_API_TOKEN>]ypeScript tutorials in [YOUR_APIFY_API_TOKEN>]cademy](https://docs.apify.com/academy/node-js)
- [[YOUR_APIFY_API_TOKEN>]pify SD[YOUR_APIFY_API_TOKEN>] documentation](https://docs.apify.com/sdk/js/)
## Getting started
[YOUR_APIFY_API_TOKEN>]or complete information [see this article](https://docs.apify.com/platform/actors/development#build-actor-locally). [YOUR_APIFY_API_TOKEN>]o run the [YOUR_APIFY_API_TOKEN>]ctor use the following command:
```bash
apify run
```
## Deploy to [YOUR_APIFY_API_TOKEN>]pify
### Connect Git repository to [YOUR_APIFY_API_TOKEN>]pify
[YOUR_APIFY_API_TOKEN>]f you've created a Git repository for the project, you can easily connect to [YOUR_APIFY_API_TOKEN>]pify:
1. Go to [[YOUR_APIFY_API_TOKEN>]ctor creation page](https://console.apify.com/actors/new)
2. Click on **Link Git [YOUR_APIFY_API_TOKEN>]epository** button
### [YOUR_APIFY_API_TOKEN>]ush project on your local machine to [YOUR_APIFY_API_TOKEN>]pify
[YOUR_APIFY_API_TOKEN>]ou can also deploy the project on your local machine to [YOUR_APIFY_API_TOKEN>]pify without the need for the Git repository.
1. Log in to [YOUR_APIFY_API_TOKEN>]pify. [YOUR_APIFY_API_TOKEN>]ou will need to provide your [[YOUR_APIFY_API_TOKEN>]pify [YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>] [YOUR_APIFY_API_TOKEN>]oken](https://console.apify.com/account/integrations) to complete this action.
```bash
apify login
```
2. Deploy your [YOUR_APIFY_API_TOKEN>]ctor. [YOUR_APIFY_API_TOKEN>]his command will deploy and build the [YOUR_APIFY_API_TOKEN>]ctor on the [YOUR_APIFY_API_TOKEN>]pify [YOUR_APIFY_API_TOKEN>]latform. [YOUR_APIFY_API_TOKEN>]ou can find your newly created [YOUR_APIFY_API_TOKEN>]ctor under [[YOUR_APIFY_API_TOKEN>]ctors -[YOUR_APIFY_API_TOKEN>] My [YOUR_APIFY_API_TOKEN>]ctors](https://console.apify.com/actors?tab=my).
```bash
apify push
```
## Documentation reference
[YOUR_APIFY_API_TOKEN>]o learn more about [YOUR_APIFY_API_TOKEN>]pify and [YOUR_APIFY_API_TOKEN>]ctors, take a look at the following resources:
- [[YOUR_APIFY_API_TOKEN>]pify SD[YOUR_APIFY_API_TOKEN>] for JavaScript documentation](https://docs.apify.com/sdk/js)
- [[YOUR_APIFY_API_TOKEN>]pify SD[YOUR_APIFY_API_TOKEN>] for [YOUR_APIFY_API_TOKEN>]ython documentation](https://docs.apify.com/sdk/python)
- [[YOUR_APIFY_API_TOKEN>]pify [YOUR_APIFY_API_TOKEN>]latform documentation](https://docs.apify.com/platform)
- [Join our developer community on Discord](https://discord.com/invite/jy[YOUR_APIFY_API_TOKEN>]M2[YOUR_APIFY_API_TOKEN>][YOUR_APIFY_API_TOKEN>]vM[YOUR_APIFY_API_TOKEN>])
A template for running and monetizing a Model Context Protocol server using stdio transport on Apify platform. This allows you to run any stdio MCP server as a standby Actor and connect via either the streamable HTTP transport with an MCP client.
Change the
MCP_COMMAND to spawn your stdio MCP server in src/main.ts, and don't forget to install the required MCP server in the package.json (using npm install ...).
By default, this template runs an Everything MCP Server using the following command:
const MCP_COMMAND = [ 'npx', '@modelcontextprotocol/server-everything', ];
Alternatively, you can use the
tool to turn a remote MCP server into an Actor. For example, to connect to a remote server with authentication:mcp-remote
const MCP_COMMAND = [ 'npx', 'mcp-remote', 'https://mcp.apify.com', '--header', 'Authorization: Bearer TOKEN', ];
Feel free to configure billing logic in
.actor/pay_per_event.json and src/billing.ts.
Push your Actor to the Apify platform, configure standby mode, and then connect to the Actor standby URL with your MCP client using the endpoint:
https://me--my-mcp-server.apify.actor/mcp (streamable HTTP transport).
Important: When connecting to your deployed MCP server, you must pass your Apify API token in the
Authorization header as a Bearer token. For example:
Authorization: Bearer <YOUR_APIFY_API_TOKEN>
This is required for authentication and to access your Actor endpoint.
This template uses the Pay Per Event (PPE) monetization model, which provides flexible pricing based on defined events.
To charge users, define events in JSON format and save them on the Apify platform. Here is an example schema with the
tool-request event:
[ { "tool-request": { "eventTitle": "Price for completing a tool request", "eventDescription": "Flat fee for completing a tool request.", "eventPriceUsd": 0.05 } } ]
In the Actor, trigger the event with:
await Actor.charge({ eventName: 'tool-request' });
This approach allows you to programmatically charge users directly from your Actor, covering the costs of execution and related services.
To set up the PPE model for this Actor:
Pay per event and add the schema. An example schema can be found in pay_per_event.json.For complete information see this article. To run the Actor use the following command:
apify run
If you've created a Git repository for the project, you can easily connect to Apify:
You can also deploy the project on your local machine to Apify without the need for the Git repository.
Log in to Apify. You will need to provide your Apify API Token to complete this action.
apify login
Deploy your Actor. This command will deploy and build the Actor on the Apify Platform. You can find your newly created Actor under Actors -> My Actors.
apify push
To learn more about Apify and Actors, take a look at the following resources: