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 operation file.
In mcp.yaml, we'll find the configuration for the MCP server.
operations:source: localpaths:- ./operations/GetFeaturedListings.graphql
In supergraph.yaml, we'll find the configuration for the supergraph.
federation_version: =2.11.0subgraphs: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 router. (Note the comment at the top of the file!)
Run the graph locally
To run the graph locally, we'll use the Rover CLI. Rover is Apollo's command line interface (CLI) tool that helps developers work with graphs.
Open a terminal and navigate to the root of the project.
Run the following command:
rover dev --supergraph-config supergraph.yaml --router-config router.yamlWe'll see some output in the terminal, with a successful message and the endpoint to get to our router in http://localhost:4000.
Navigate to http://localhost:4000 in the browser. We'll see the Apollo Sandbox connected to the endpoint, ready for us to query our local router.
Try running the following query:
query GetFeaturedListings {featuredListings {idtitledescriptioncostPerNightnumOfBedslocationType}}We should see the data for the featured listings returned!
This is our graph working by itself, without any AI agents involved. Let's add the MCP server to the mix.
Run the graph and MCP server locally
Stop the
rover devcommand withCtrl+C.Run the same command but this time with the
--mcpflag pointing to themcp.yamlfile.rover dev --supergraph-config supergraph.yaml --router-config router.yaml --mcp mcp.yamlWe'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.
In a new terminal window, run the following command:
npx @modelcontextprotocol/inspector http://127.0.0.1:5000/mcp --transport httpThis will open up a new tab in the browser to
http://localhost:6274/.Click the Connect button.
In the Tools tab, we should see the tools exposed by the server, and test them directly.
Click List Tools.
Right now, we only have one tool exposed:
GetFeaturedListings. Click on it.Click the Run Tool button.
We should see some data for the featured listings returned, the same ones we saw earlier when we ran the query against the local router.