3. Follow-along: Run the MCP server
1m

Follow-along: Run the MCP server

🎯 Goal: Run the MCP server locally and use MCP Inspector to test a pre-defined tool.

Project structure

Open up the project folder in your code editor.

📂 workshop-mcp-intro
┣ 📂 operations
┣ ┗ 📄 GetFeaturedListings.graphql
┣ 📄 mcp.yaml
┣ 📄 router.yaml
┗ 📄 supergraph.yaml

We have a few config files and an file.

In mcp.yaml, we'll find the configuration for the MCP server.

mcp.yaml
operations:
source: local
paths:
- ./operations/GetFeaturedListings.graphql

In supergraph.yaml, we'll find the configuration for the .

supergraph.yaml
federation_version: =2.11.0
subgraphs:
listings:
routing_url: https://rt-airlock-subgraphs-listings.herokuapp.com/
schema:
subgraph_url: https://rt-airlock-subgraphs-listings.herokuapp.com/
# accounts:
# routing_url: https://rt-airlock-subgraphs-accounts.herokuapp.com/
# schema:
# subgraph_url: https://rt-airlock-subgraphs-accounts.herokuapp.com/
# bookings:
# routing_url: https://rt-airlock-subgraphs-bookings.herokuapp.com/
# schema:
# subgraph_url: https://rt-airlock-subgraphs-bookings.herokuapp.com/
# reviews:
# routing_url: https://rt-airlock-subgraphs-reviews.herokuapp.com/
# schema:
# subgraph_url: https://rt-airlock-subgraphs-reviews.herokuapp.com/
# payments:
# routing_url: https://rt-airlock-subgraphs-payments.herokuapp.com/
# schema:
# subgraph_url: https://rt-airlock-subgraphs-payments.herokuapp.com/

We're working with just one service for now (listings). We'll open up the rest later on.

In router.yaml, we'll find minimal configuration for the local . (Note the comment at the top of the file!)

Run the graph locally

To run the locally, we'll use the . Rover is Apollo's command line interface (CLI) tool that helps developers work with graphs.

  1. Open a terminal and navigate to the root of the project.

  2. Run the following command:

    rover dev --supergraph-config supergraph.yaml --router-config router.yaml
  3. We'll see some output in the terminal, with a successful message and the endpoint to get to our in http://localhost:4000.

  4. Navigate to http://localhost:4000 in the browser. We'll see the connected to the endpoint, ready for us to our local .

  5. Try running the following :

    query GetFeaturedListings {
    featuredListings {
    id
    title
    description
    costPerNight
    numOfBeds
    locationType
    }
    }
  6. We should see the data for the featured listings returned!

This is our working by itself, without any AI agents involved. Let's add the MCP server to the mix.

Run the graph and MCP server locally

  1. Stop the rover dev command with Ctrl+C.

  2. Run the same command but this time with the --mcp flag pointing to the mcp.yaml file.

    rover dev --supergraph-config supergraph.yaml --router-config router.yaml --mcp mcp.yaml
  3. We'll see some output in the terminal, with a successful message and the endpoint to get to our MCP server in http://127.0.0.1:5000.

Run the MCP Inspector

MCP Inspector is a tool that helps us inspect and debug MCP servers. It's a web-based tool that allows us to see the tools exposed by the server, and test them directly.

  1. In a new terminal window, run the following command:

    npx @modelcontextprotocol/inspector http://127.0.0.1:5000/mcp --transport http
  2. This will open up a new tab in the browser to http://localhost:6274/.

  3. Click the Connect button.

  4. In the Tools tab, we should see the tools exposed by the server, and test them directly.

  5. Click List Tools.

  6. Right now, we only have one tool exposed: GetFeaturedListings. Click on it.

  7. Click the Run Tool button.

  8. We should see some data for the featured listings returned, the same ones we saw earlier when we ran the against the local .

How many featured listings are there?
Previous