2. Follow-along: Run the MCP server
2m

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-security
┣ 📂 graph
┣ ┣ 📄 listings-schema.graphql
┣ ┣ 📄 router.yaml
┣ ┗ 📄 supergraph.yaml
┣ 📂 mcp
┣ ┣ 📂 operations
┣ ┣ ┣ 📄 GetListingDetails.graphql
┣ ┣ ┗ 📄 GetUser.graphql
┣ ┗ 📄 mcp.yaml
┗ 📄 commands.sh
  • 📂 graph contains the listings , configuration, and configuration.
  • 📂 mcp contains the MCP server configuration and we're using as tools.
  • commands.sh contains the commands to run the and MCP server locally.

The MCP server configuration

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

mcp/mcp.yaml
endpoint: http://127.0.0.1:4000/
transport:
type: streamable_http
operations:
source: local
paths:
- ./mcp/operations/GetListingDetails.graphql
- ./mcp/operations/GetUser.graphql
introspection:
execute:
enabled: true
introspect:
enabled: true
search:
enabled: true
validate:
enabled: true

We're using local to define the tools for the MCP server. tools are also enabled.

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 graph/supergraph.yaml --router-config graph/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 GetListingDetails {
listing(id: "listing-1") {
id
title
description
numOfBeds
costPerNight
locationType
photoThumbnail
amenities {
name
category
}
}
}
  1. We should see the data for the a listing 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 graph/supergraph.yaml --router-config graph/router.yaml --mcp 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@0.16.7 http://127.0.0.1:5000/mcp --transport http

    We're pinning this version specifically because later versions have known bugs working with OAuth. We're also setting the URL endpoint and the transport type.

  2. This will automatically open up a new tab in the browser.

  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. You should see a few tools listed (you can scroll within the tools section). Find the GetListingDetails tool. Click on it.

  7. Input in listing-1 as the value for the listingId and click the Run Tool button.

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

How many amenities does the listing have?
Previous