Apollo GraphQL MCP server

Enables AI agents to interact with GraphQL APIs by exposing operations as tools, supporting both local schema files and Apollo GraphOS integration with features for introspection and custom scalar mapping.
Back to servers
Setup instructions
Provider
Apollo GraphQL
Release date
May 16, 2025
Language
Go
Stats
165 stars

The Apollo MCP Server is a tool that exposes GraphQL operations as Model Context Protocol (MCP) tools. This integration allows you to leverage your GraphQL API within the MCP ecosystem, enabling more powerful interactions between your data and large language models.

Installation

To install the Apollo MCP Server, you can use npm or yarn:

# Using npm
npm install @apollo/mcp-server

# Using yarn
yarn add @apollo/mcp-server

Setting Up Your Server

Basic Configuration

Create a new file for your MCP server implementation:

// mcp-server.js
import { ApolloMCPServer } from '@apollo/mcp-server';
import { ApolloServer } from '@apollo/server';

// Create your Apollo Server with your GraphQL schema
const apolloServer = new ApolloServer({
  typeDefs: `
    type Query {
      hello: String
    }
  `,
  resolvers: {
    Query: {
      hello: () => 'Hello world!'
    }
  }
});

// Create the MCP Server
const mcpServer = new ApolloMCPServer({
  apolloServer,
  tools: [
    // Define your MCP tools here
  ]
});

// Start the server
const start = async () => {
  await mcpServer.start();
  console.log('MCP Server is running');
};

start();

Defining MCP Tools

You can define MCP tools based on your GraphQL operations:

// Define tools based on GraphQL operations
const tools = [
  {
    name: 'getUser',
    description: 'Get user information by ID',
    operation: `
      query GetUser($id: ID!) {
        user(id: $id) {
          id
          name
          email
        }
      }
    `,
    parameters: {
      type: 'object',
      properties: {
        id: {
          type: 'string',
          description: 'The ID of the user to fetch'
        }
      },
      required: ['id']
    }
  }
]

Usage Examples

Starting the Server

To start your MCP server:

node mcp-server.js

By default, the server listens on port 3000. You can customize the port:

// Custom port configuration
const mcpServer = new ApolloMCPServer({
  apolloServer,
  tools,
  port: 4000
});

Connecting to LLM Services

To use your MCP server with LLM services, you'll need to provide the server URL to your LLM provider:

// Example of configuring an LLM client to use your MCP server
const llmClient = new SomeLLMClient({
  model: "gpt-4",
  mcpServers: ["http://localhost:3000/mcp"]
});

Creating Complex Tools

You can create more complex tools with nested parameters:

{
  name: 'searchProducts',
  description: 'Search for products with filters',
  operation: `
    query SearchProducts($query: String!, $filter: ProductFilterInput) {
      searchProducts(query: $query, filter: $filter) {
        id
        name
        price
        description
      }
    }
  `,
  parameters: {
    type: 'object',
    properties: {
      query: {
        type: 'string',
        description: 'Search query string'
      },
      filter: {
        type: 'object',
        properties: {
          minPrice: {
            type: 'number',
            description: 'Minimum price filter'
          },
          maxPrice: {
            type: 'number',
            description: 'Maximum price filter'
          },
          category: {
            type: 'string',
            description: 'Product category'
          }
        }
      }
    },
    required: ['query']
  }
}

Advanced Configuration

Authentication

You can add authentication to your MCP server:

const mcpServer = new ApolloMCPServer({
  apolloServer,
  tools,
  context: async ({ req }) => {
    // Get auth token from request
    const token = req.headers.authorization || '';
    
    // Validate token and get user
    const user = await validateToken(token);
    
    return { user };
  }
});

Error Handling

Add custom error handling to provide better feedback:

const mcpServer = new ApolloMCPServer({
  apolloServer,
  tools,
  formatError: (error) => {
    console.error('GraphQL error:', error);
    
    return {
      message: error.message,
      code: error.extensions?.code || 'INTERNAL_SERVER_ERROR',
      path: error.path
    };
  }
});

For more detailed information and advanced configurations, visit the official Apollo MCP Server documentation.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "apollo-mcp-server" '{"command":"npx","args":["-y","apollo-mcp-server"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "apollo-mcp-server": {
            "command": "npx",
            "args": [
                "-y",
                "apollo-mcp-server"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "apollo-mcp-server": {
            "command": "npx",
            "args": [
                "-y",
                "apollo-mcp-server"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later