Apify MCP Server Template

Apify MCP Server Template

A template for creating and deploying Model Context Protocol servers on the Apify platform using FastMCP, with built-in support for pay-per-event monetization and standby mode hosting.

Category
Visit Server

README

MCP server template

<!-- This is an Apify template readme -->

A template for creating a Model Context Protocol server using FastMCP on Apify platform.

This template includes a simple example MCP server with:

  • An add tool that adds two numbers together with structured output
  • A dummy calculator-info resource endpoint
  • Pay Per Event monetization support

How to use

  1. Modify the server: Edit src/main.py to add your own tools and resources
  2. Add new tools: Use the @server.tool() decorator to register new tools
  3. Add new resources: Use the @server.resource() decorator to register new resources
  4. Update billing: Configure billing events in .actor/pay_per_event.json and charge for tool calls

The server runs on port 3000 (or APIFY_CONTAINER_PORT if set) and exposes the MCP protocol at the /mcp endpoint.

Running locally

pip install -r requirements.txt
APIFY_META_ORIGIN=STANDBY python -m src

The server will start and listen for MCP requests at http://localhost:3000/mcp

Deploying to Apify

Push your Actor to the Apify platform and configure standby mode.

Then connect to the Actor endpoint with your MCP client: https://me--my-mcp-server.apify.actor/mcp using the Streamable HTTP transport.

Important: When connecting to your deployed MCP server, pass your Apify API token in the Authorization header as a Bearer token:

Authorization: Bearer <YOUR_APIFY_API_TOKEN>

Pay per event

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-call event:

{
    "tool-call": {
        "eventTitle": "Price for completing a tool call",
        "eventDescription": "Flat fee for completing a tool call.",
        "eventPriceUsd": 0.05
    }
}

In the Actor, trigger the event with:

await Actor.charge(event_name='tool-call')

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:

  • Configure Pay Per Event: establish the Pay Per Event pricing schema in the Actor's Monetization settings. First, set the Pricing model to Pay per event and add the schema. An example schema can be found in pay_per_event.json.

Resources

Getting started

For complete information see this article. To run the Actor use the following command:

apify run

Deploy to Apify

Connect Git repository to Apify

If you've created a Git repository for the project, you can easily connect to Apify:

  1. Go to Actor creation page
  2. Click on Link Git Repository button

Push project on your local machine to Apify

You can also deploy the project on your local machine to Apify without the need for the Git repository.

  1. Log in to Apify. You will need to provide your Apify API Token to complete this action.

    apify login
    
  2. 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
    

Documentation reference

To learn more about Apify and Actors, take a look at the following resources:

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured