Build and Inspect an MCP Demo
Build a local MCP server with tools, resources, prompts, and saved state.
Introduction
30 Second Summary
A helpful assistant becomes frustrating when it can recommend a task but cannot remember that you started it. The missing connection stays invisible until you can watch a request travel through every layer.
In this project, you will build a local NextWork-style MCP server for a project recommendation workflow. You will observe each request in MCP Inspector before running the workflow through Claude Desktop.
What You'll Build
You ask Claude Desktop for an easy cloud project and watch progress.json record it as in_progress after Claude uses your local server.
By the end of this project, you'll have:
- A Claude-powered project workflow that finds a matching demo and records its start status in a local progress file.
- A visible MCP architecture that lets you trace one request through the MCP host, MCP client, local server, and stdio transport.
- Generated MCP primitive views in MCP Inspector that expose callable tools, a readable progress resource, and a reusable recommendation prompt.
- Secret Mission: An optional challenge to push your MCP architecture skills further.
Are there any prerequisites?
You'll need macOS with Python and Node.js already installed. You'll also need Claude Desktop installed and opened at least once.
An existing code editor completes your local setup.
Before We Start
Before any setup begins, lock in what this demo lets Claude do and which MCP components you want to observe. This keeps every later action tied to the architecture you are here to make visible.
Set Up the Local MCP Toolchain
A compatible local runtime keeps environment failures out of the way so this project can focus on MCP behavior.
You'll confirm each local prerequisite before creating an isolated environment. The pinned MCP Python SDK gives later MCP clients one predictable Python runtime.
In this step, get ready to:
- Verify Python 3.11 or later plus a supported Node.js version.
- Create an active .venv with mcp==2.3.0 installed.
- Prepare the progress and Inspector configuration files with your absolute project path.
Confirm the installed runtimes
MCP Inspector runs through Node.js. Claude Desktop must also create its local configuration directory before you connect a server.
- Press Cmd+Space to open Spotlight.
- Type Terminal.
- Press Enter to open Terminal.
- Check your installed Python version by running this command:
python3 --version
What does this command do?
The --version flag asks the Python executable to print its installed version. This confirms whether the server can use the current MCP Python SDK.
✔️ I see a supported version
Your output shows Python 3.11 or later. Python is ready for the demo.
ⓧ I see an older version
- Download the Python 3.15.2 macOS installer from the official Python downloads page.
- Open the downloaded installer package.
- Select Continue in the installer.
- Select Agree for the license terms.
- Select Install to complete the installation.
- Run Install Certificates.command from the new Python folder in Applications.
- Return to Terminal to check the upgraded version by running:
python3 --version
What does this command do?
This repeats the version check against the Python executable found by Terminal. You should now see Python 3.15.2.
ⓧ Command not found
- Download the Python 3.15.2 macOS installer from the official Python downloads page.
- Open the downloaded installer package.
- Select Continue in the installer.
- Select Agree for the license terms.
- Select Install to complete the installation.
- Run Install Certificates.command from the new Python folder in Applications.
- Return to Terminal to confirm Python is available by running:
python3 --version
What does this command do?
This asks the newly installed Python executable for its version. You should now see Python 3.15.2.
Your Python output should show version 3.11 or later.
- Check your installed Node.js version by running this command:
node --version
What does this command do?
This prints the version of Node.js available in Terminal. MCP Inspector 2.16.0 supports three current Node.js release lines.
✔️ I see a supported version
The supported ranges are 22.23.4+, 24.22.1+, or 26.12.1+. Your Node.js runtime is ready.
ⓧ I see an unsupported version
- Download Node.js v26.13.1 LTS from the official Node.js download page.
- Open the downloaded macOS package.
- Complete the installer prompts.
- Return to Terminal to check the upgraded version by running:
node --version
What does this command do?
This repeats the Node.js version check after installation. You should now see v26.13.1 or a later supported version.
ⓧ Command not found
- Download Node.js v26.13.1 LTS from the official Node.js download page.
- Open the downloaded macOS package.
- Complete the installer prompts.
- Return to Terminal to confirm Node.js is available by running:
node --version
What does this command do?
This asks the newly installed Node.js executable for its version. You should now see v26.13.1 or a later supported version.
Your Node.js output should fall within 22.23.4+, 24.22.1+, or 26.12.1+.
- Open Claude Desktop once so it creates its local configuration directory.
- Press Cmd+Space to open Spotlight.
- Type Claude Desktop.
- Press Enter to open the app.
You should see Claude Desktop load. Its local configuration directory is now available for the connection you add later.
Create the isolated project environment
A virtual environment keeps this project's Python packages separate from the rest of your Mac. Activating it also gives MCP clients a dedicated Python executable.
- Switch back to Terminal.
- Move to your Desktop by running this command:
cd ~/Desktop
What does this command do?
The cd command changes Terminal's current folder. The ~ shortcut points to your macOS home folder.
- Create the nextwork-mcp-demo folder and move into it by running these commands:
mkdir nextwork-mcp-demo
cd nextwork-mcp-demo
What do these commands do?
- The mkdir command creates the project folder on your Desktop.
- The second command changes Terminal's current location to that new folder.
- Confirm Terminal is inside the project folder by running:
pwd
What does this command do?
The pwd command prints Terminal's current absolute path. This gives you a concrete location for every file that follows.
The output should end with Desktop/nextwork-mcp-demo.
- Create the isolated Python environment by running:
python3 -m venv .venv
What does this command do?
Python creates a .venv directory containing a separate interpreter and package location. Later clients can launch that interpreter directly.
- Activate the new environment by running:
source .venv/bin/activate
What does this command do?
The source command updates the current Terminal session to use the environment's Python tools. Your prompt now identifies the active environment.
You should see the environment name at the start of your Terminal prompt.
- Open a new requirements.txt file in Nano by running:
nano requirements.txt
What does this command do?
Nano opens requirements.txt inside Terminal. The file records the exact Python package version required by this demo.
- Paste this dependency pin into requirements.txt.
mcp==2.3.0
What does this code do?
The exact == specifier pins the MCP Python SDK to version 2.3.0. Every learner gets the same SDK behavior.
- Save requirements.txt and return to Terminal.
- Press Ctrl+O to write the file.
- Press Enter to confirm the filename.
- Press Ctrl+X to exit Nano.
- Install the pinned SDK into the active environment by running:
python3 -m pip install -r requirements.txt
What does this command do?
Python runs pip inside the active environment. Pip reads requirements.txt before installing the pinned SDK and its dependencies.
You should see the installation finish successfully. The active environment now contains the MCP Python SDK.
Package installation failed?
- Check that your prompt still identifies the active environment.
- Confirm requirements.txt contains only mcp==2.3.0.
Help me diagnose why the MCP Python SDK installation failed.
Prepare the local data and Inspector configuration
The progress file begins as an empty local state store. The Inspector configuration tells the client which Python executable to launch.
Copying the absolute path is a little fiddly because Finder hides the command behind the Option key.
- Copy the absolute pathname for the nextwork-mcp-demo folder from Finder.
- Press Cmd+Space to open Spotlight.
- Type Finder.
- Press Enter to open Finder.
- Select Desktop in the Finder sidebar.
- Hold Option while right-clicking the nextwork-mcp-demo folder.
- Select Copy “nextwork-mcp-demo” as Pathname.
- Switch back to Terminal.
- Open a new progress.json file in Nano by running:
nano progress.json
What does this command do?
Nano creates progress.json in the current project folder. This file holds visible learner state later in the demo.
- Paste this empty JSON object into progress.json.
{}
What does this code do?
The empty object gives the server a valid starting state. Later tools add project IDs and saved statuses to this file.
- Save progress.json and return to Terminal.
- Press Ctrl+O to write the file.
- Press Enter to confirm the filename.
- Press Ctrl+X to exit Nano.
- Confirm the new file exists by running:
ls
What does this command do?
The ls command lists files in the current folder. It gives you a quick check without leaving Terminal.
You should see progress.json and requirements.txt in the output.
- Open a new inspector-config.json file in Nano by running:
nano inspector-config.json
What does this command do?
Nano creates the MCP Inspector configuration file in your project folder. The client reads this file to find the local server command.
- Write inspector-config.json from the template below. Substitute the copied folder pathname for each <absolute-project-path>/nextwork-mcp-demo placeholder before you paste it.
{
"mcpServers": {
"nextwork-demo": {
"command": "<absolute-project-path>/nextwork-mcp-demo/.venv/bin/python",
"args": [
"<absolute-project-path>/nextwork-mcp-demo/server.py"
]
}
}
}
What does this code do?
- The mcpServers object holds local server definitions that Inspector can launch.
- The command value points to Python inside your isolated environment.
- The args array points that Python process at the server file added in the next step.
- Save inspector-config.json and return to Terminal.
- Press Ctrl+O to write the file.
- Press Enter to confirm the filename.
- Press Ctrl+X to exit Nano.
- Confirm all three project files exist by running:
ls
What does this command do?
This lists the current project files again. The new Inspector configuration should now appear beside the other two files.
You should see inspector-config.json, progress.json, and requirements.txt.
✔️ Awesome, I've got everything!
Great. Double-check that every file is saved before the final toolchain check.
ⓧ I'd like to double check the full code
Compare each file with these complete references. Your Inspector paths contain your real copied pathname in place of the placeholder.
mcp==2.3.0
{}
{
"mcpServers": {
"nextwork-demo": {
"command": "<absolute-project-path>/nextwork-mcp-demo/.venv/bin/python",
"args": [
"<absolute-project-path>/nextwork-mcp-demo/server.py"
]
}
}
}
Before you run the final checks, do you expect both commands to confirm a compatible toolchain?
- Verify the installed SDK and Node.js runtime by running:
python3 -m pip freeze
node --version
What do these commands do?
- The first command prints the packages installed inside the active environment.
- The second command prints the Node.js version available to MCP Inspector.
The first output should include mcp==2.3.0. The second output should fall within an Inspector-supported Node.js release line.
Your local toolchain is ready. The isolated Python environment and client configuration now point toward the same project folder.
Next, you'll turn this setup into a read-only MCP server and inspect the capabilities it exposes.
Inspect the Read-Only Server
Your active environment is ready. You can now turn the empty project into a server that a client can discover.
A compatible local runtime lets MCP Inspector reveal server behavior without environment failures.
In this step, get ready to:
- Create a read-only MCP server that exposes search_projects. It also exposes get_project.
- Connect MCP Inspector through stdio. Its Tools view shows both generated schemas.
- Call both tools. The project response reports not_started while progress.json remains {}.
Build the read-only server
The MCPServer instance holds the capabilities a client can discover. Decorated Python functions become tools with generated descriptions and input schemas.
- Return to Claude Desktop from earlier.
- Ask Claude Desktop to draft the read-only server.py described by this step.
- Limit the draft to project search plus project detail retrieval.
- Tell Claude to keep mcp.run() under the if __name__ == "__main__": guard.
- Save the draft as server.py inside the existing nextwork-mcp-demo folder.
Compare Claude's draft with the supplied source before launching it.
✔️ I'll try it first
Your draft should contain the server instance, mock catalog, progress helpers, two read-only tools, and the guarded run entry point.
ⓧ Let me check the full code
- Replace your draft with this reference if any line differs:
import json
from pathlib import Path
from mcp.server import MCPServer
from mcp.types import ToolAnnotations
mcp = MCPServer("NextWork Demo")
BASE_DIR = Path(__file__).parent
PROGRESS_FILE = BASE_DIR / "progress.json"
PROJECTS: list[dict[str, str]] = [
{
"id": "static-website",
"title": "Launch a Static Website",
"topic": "cloud",
"difficulty": "easy",
"summary": "Publish a small website and verify that visitors can load it.",
},
{
"id": "container-api",
"title": "Containerize a Small API",
"topic": "containers",
"difficulty": "medium",
"summary": "Package a small service so it runs consistently in a container.",
},
{
"id": "data-dashboard",
"title": "Build a Data Dashboard",
"topic": "data",
"difficulty": "easy",
"summary": "Turn a sample dataset into a simple visual dashboard.",
},
]
def find_project(project_id: str) -> dict[str, str] | None:
for project in PROJECTS:
if project["id"] == project_id:
return project
return None
def load_progress() -> dict[str, str]:
if not PROGRESS_FILE.exists():
return {}
try:
return json.loads(PROGRESS_FILE.read_text(encoding="utf-8"))
except (json.JSONDecodeError, OSError):
return {}
def save_progress(progress: dict[str, str]) -> None:
PROGRESS_FILE.write_text(
json.dumps(progress, indent=2, sort_keys=True),
encoding="utf-8",
)
@mcp.tool(
title="Search demo projects",
annotations=ToolAnnotations(read_only_hint=True, open_world_hint=False),
)
def search_projects(topic: str = "", difficulty: str = "") -> str:
"""Search demo projects by topic and difficulty."""
topic_filter = topic.strip().lower()
difficulty_filter = difficulty.strip().lower()
matches = [
project
for project in PROJECTS
if (
not topic_filter
or topic_filter in project["topic"].lower()
or topic_filter in project["title"].lower()
)
and (
not difficulty_filter
or difficulty_filter == project["difficulty"].lower()
)
]
if not matches:
return "No matching demo projects."
return "\n".join(
f"{project['id']}: {project['title']} "
f"({project['topic']}, {project['difficulty']})"
for project in matches
)
@mcp.tool(
title="Get demo project details",
annotations=ToolAnnotations(read_only_hint=True, open_world_hint=False),
)
def get_project(project_id: str) -> str:
"""Get details and saved status for one demo project."""
project = find_project(project_id)
if project is None:
return f"No demo project has the ID {project_id}."
status = load_progress().get(project_id, "not_started")
return (
f"Title: {project['title']}\n"
f"Topic: {project['topic']}\n"
f"Difficulty: {project['difficulty']}\n"
f"Summary: {project['summary']}\n"
f"Status: {status}"
)
if __name__ == "__main__":
mcp.run()
What does this code do?
- The MCPServer instance gives the local server its identity.
- The PROJECTS list supplies three records for the demo catalog.
- The progress helpers read local state from progress.json.
- The save_progress helper exists inside Python. No MCP tool exposes it to clients in this server state.
- Each @mcp.tool decorator turns its function into a discoverable MCP capability.
- The function name becomes the tool name. The docstring becomes its description.
- The type hints become the generated input schema.
Your server.py now matches the complete read-only server source.
Observe discovery and generated schemas
Inspector acts as an MCP host with an embedded MCP client. The client launches your Python process locally before discovering its advertised capabilities.
Before you launch, consider whether the browser will reveal both tool schemas from the Python decorators.
- Launch the pinned Inspector with your existing configuration by running this command:
npx @modelcontextprotocol/inspector@2.16.0 --config inspector-config.json
What does this command do?
- The npx command launches the pinned MCP Inspector package.
- The @2.16.0 suffix selects the project version.
- The --config option loads inspector-config.json.
- That configuration launches .venv/bin/python with your local server.py.
The first launch may pause while npx retrieves the pinned package.
- Approve the package download if Terminal asks for confirmation.
- Connect Inspector to nextwork-demo from inspector-config.json.
- Use Inspector's connection screen to choose nextwork-demo if it asks you to select a configured server.
Your browser opens MCP Inspector. The connection shows the local nextwork-demo server.
What is happening across stdio?
Inspector launches your server as a subprocess. It sends requests through standard input.
The server returns responses through standard output. This local connection needs no network port.
- Compare the generated schema for search_projects with its Python definition.
- Select Tools in Inspector.
- Select search_projects from the tool list.
- Match its displayed name to the Python function name.
- Match its displayed description to the Python docstring.
- Match its generated fields to the Python type hints.
The search_projects schema contains generated fields for topic plus difficulty.
- Compare the generated schema for get_project with its Python definition.
- Return to the Tools list.
- Select get_project.
- Match its displayed name to the Python function name.
- Match its displayed description to the Python docstring.
- Match its generated field to the Python type hint.
The get_project schema contains one generated field named project_id.
- Open Inspector's monitoring view.
- Identify the initialization request.
- Identify the server's capability discovery response.
- Find tools/list in the recorded activity.
That is your first MCP contract made visible. Inspector discovered both tools directly from the running Python server.
Call the read-only tools
Discovery shows what a server offers. Tool calls prove that a client can send structured arguments before receiving a result.
- Set the topic argument for search_projects to cloud.
- Select search_projects in the Tools view.
- Enter cloud in the generated topic field.
- Set the difficulty argument to easy.
- Enter easy in the generated difficulty field.
- Call search_projects with the completed form.
- Submit the generated tool form.
You'll see static-website: Launch a Static Website (cloud, easy) in the result.
Before the detail call, predict which saved status the untouched progress.json file produces.
- Set the project_id argument for get_project to static-website.
- Return to the Tools list.
- Select get_project.
- Enter static-website in the generated project_id field.
- Call get_project with the completed form.
- Submit the generated tool form.
The response includes Launch a Static Website plus its project summary. It ends with Status: not_started.
- Return to Inspector's monitoring view.
- Find the later tools/call requests.
- Switch to progress.json in your code editor.
- Select progress.json from your editor's file list.
The file still contains {}. Inspector lists no tool that can change this state.
Inspector not connecting?
- Keep the Inspector process running in Terminal while you use its browser interface.
- Confirm that inspector-config.json still contains the absolute path to .venv/bin/python.
- Confirm that the configured argument ends with the absolute path to server.py.
Help me diagnose why MCP Inspector cannot connect to my local stdio server.
Your read-only server can now answer project questions through MCP. Next, you'll connect the same server to Claude Desktop and expose the missing action.
Connect Claude and Test the Missing Action
Your read-only server already proved its contract in MCP Inspector. Now you will connect the same process to Claude Desktop through its embedded MCP client.
Connecting the server to a real MCP host makes the host-client-server boundary visible before you test whether the current contract can persist progress.
In this step, get ready to:
- Register the local server in Claude Desktop while preserving every existing server entry.
- Restart Claude Desktop and confirm that it discovers both read-only tools.
- Test whether Claude can start a project and confirm that progress remains unchanged.
Register the local server
Claude Desktop reads a configuration file to learn which local server process it can launch. The entry points Claude to the virtual environment's Python executable plus your existing server.py file.
- Open Claude Desktop's local MCP configuration file.
- Press Cmd+Space to open macOS search.
- Type Claude into the search bar.
- Press Enter to open Claude Desktop.
- Click Settings.
- Select Developer.
- Click Edit Config to open ~/Library/Application Support/Claude/claude_desktop_config.json.
Merging this JSON is a little fiddly because your existing server entries must remain in the file.
- Merge the entire nextwork-demo entry from inspector-config.json into the root mcpServers object in claude_desktop_config.json.
- Keep every existing server entry inside mcpServers.
- Keep a comma between sibling server entries.
- In your code editor's file sidebar, select inspector-config.json from the nextwork-mcp-demo folder.
- Copy the complete nextwork-demo object from inside mcpServers.
- Return to the claude_desktop_config.json file opened by Claude Desktop.
- Locate the root mcpServers object.
- Paste nextwork-demo beside any existing server entries.
- Save claude_desktop_config.json.
- Press Cmd+S to save the file.
Your saved configuration now contains nextwork-demo with the same absolute command path plus the same args path used by Inspector.
- Compare your saved Claude Desktop configuration with the reference below.
✔️ My server entry is merged
Your nextwork-demo entry uses your real absolute paths. Any other configured servers remain beside it.
ⓧ I'd like to double check the full code
{
"mcpServers": {
"nextwork-demo": {
"command": "<absolute-project-path>/nextwork-mcp-demo/.venv/bin/python",
"args": [
"<absolute-project-path>/nextwork-mcp-demo/server.py"
]
}
}
}
What does this configuration do?
- The mcpServers object groups the local servers available to Claude Desktop.
- The command value launches Python from your isolated .venv environment.
- The args array points that Python process to server.py.
- The <absolute-project-path> marker represents the real path already present in inspector-config.json.
Restart Claude Desktop and confirm the connection
Claude Desktop loads its local server configuration during startup. A full restart makes the host launch a fresh stdio transport process from your saved paths.
- Fully quit Claude Desktop.
- Select the Claude Desktop application menu in the macOS menu bar.
- Choose the quit option to close the complete application process.
- Reopen Claude Desktop.
- Press Cmd+Space to open macOS search.
- Type Claude into the search bar.
- Press Enter to reopen Claude Desktop.
Claude Desktop now reloads claude_desktop_config.json and launches the registered server process.
- Confirm that nextwork-demo is connected in Claude Desktop.
- Open Add files, connectors, and more.
- Select Connectors.
- Open Manage connectors.
- Select nextwork-demo from the connector list.
- Confirm that the server exposes search_projects.
- Confirm that the server exposes get_project.
You should see nextwork-demo connected with exactly two read-only tools. That confirms Claude Desktop can discover the same server contract you inspected earlier.
Server not connecting?
- Confirm that claude_desktop_config.json has matching braces plus valid commas between server entries.
- Confirm that command exactly matches the Python path from inspector-config.json.
- Confirm that the file path in args exactly matches the existing server.py path.
Help me diagnose why Claude Desktop cannot connect to my local nextwork-demo MCP server.
Trigger the missing action
Claude can only call capabilities that the server advertises. This request combines project discovery with a request to change saved progress.
Before you ask, do you think Claude can complete the whole request using only the two tools it discovered?
- Send this request to Claude:
Find an easy cloud project and start it for me
What does this prompt test?
The request asks Claude to find a matching project before inspecting its details. It also asks the server to change the learner's saved state.
- Review the tool name plus arguments for each proposed call.
- Approve each read-only tool call after your review.
- Read the tool name shown in Claude's tool-call card.
- Read the argument values shown in the same card.
- Use the approval control in that card to allow the call.
Claude can call search_projects to find static-website. It can call get_project to inspect that project.
Claude cannot persist the requested start because the server exposes no start_project tool. This shortfall is the intended result.
You have now proved that the model cannot create a server capability by itself. The host can only offer what the server advertises.
Before you inspect the saved file, do you expect it to contain a project status?
- Open progress.json from the nextwork-mcp-demo folder in your existing code editor.
- Select progress.json from your code editor's file sidebar.
You should still see {}. The empty object proves that the read-only tools returned information without saving a started state.
Claude can now search your local catalog through a real host, but the missing action keeps progress unchanged. Next, you will add the write capability plus the remaining MCP primitives.
Add State, Resources, and Prompts
Your read-only demo made the missing capability visible. Claude could find a project but could not save a started state.
The missing write capability closes the persistence gap while the new read and template surfaces make their different controllers visible.
In this step, get ready to:
- Add a state-changing MCP tool that saves a project with an in-progress status.
- Expose an MCP resource for saved progress plus an MCP prompt for project recommendations.
- Verify the completed server in MCP Inspector plus Claude Desktop.
Complete the server
The server already knows how to load progress from progress.json and save changes back to it. The new tool connects that persistence layer to a request from a client.
- Find the if __name__ == "__main__": guard near the bottom of server.py.
- Insert the following tool directly above the guard:
@mcp.tool(
title="Start a demo project",
annotations=ToolAnnotations(
read_only_hint=False,
destructive_hint=False,
idempotent_hint=True,
open_world_hint=False,
),
)
def start_project(project_id: str) -> str:
"""Mark one demo project as in progress."""
project = find_project(project_id)
if project is None:
return f"No demo project has the ID {project_id}."
progress = load_progress()
progress[project_id] = "in_progress"
save_progress(progress)
return f"Started {project['title']}. Saved status: in_progress."
What does this code do?
- The annotations tell clients that start_project changes local state without performing a destructive action.
- The function rejects a project ID that is absent from PROJECTS.
- A valid project receives the in_progress status before save_progress() writes the updated dictionary to disk.
- Save server.py.
Before you test the tool, do you expect its result to exist only in the Inspector or remain visible in progress.json?
- Launch the pinned Inspector with your existing configuration by running this command:
npx @modelcontextprotocol/inspector@2.16.0 --config inspector-config.json
What does this command do?
- The npx command launches the Inspector package without adding it to your project dependencies.
- The 2.16.0 pin keeps the Inspector version consistent with the toolchain you checked earlier.
- The --config option loads the command plus arguments stored in inspector-config.json.
- Connect Inspector to nextwork-demo.
- Choose nextwork-demo from the configured server list.
- Submit the connection request.
- Call start_project with project_id set to static-website.
- Select Tools.
- Choose start_project.
- Enter static-website in the generated project_id field.
- Submit the tool call.
You should see a successful result with the saved status set to in_progress. The same status now persists in progress.json.
New tool missing?
- Stop any earlier Inspector process before launching the pinned command again.
- Confirm that inspector-config.json still points to this project's server.py file.
- Check that .venv remains active in Terminal.
Help me diagnose why MCP Inspector cannot discover the new start_project tool.
- Stop the current Inspector process by pressing Ctrl+C in Terminal.
A resource gives the application a stable address for reading the current project state. Returning JSON keeps every project status structured for the client.
- Return to the if __name__ == "__main__": guard in server.py.
- Insert the following resource directly above the guard:
@mcp.resource("nextwork://learner/progress", mime_type="application/json")
def learner_progress() -> str:
"""Current project status for the demo learner."""
progress = load_progress()
payload = [
{
"project_id": project["id"],
"title": project["title"],
"status": progress.get(project["id"], "not_started"),
}
for project in PROJECTS
]
return json.dumps(payload, indent=2)
What does this code do?
- The decorator assigns learner progress the address nextwork://learner/progress.
- The list comprehension creates one structured record for every project in PROJECTS.
- Projects without a saved value receive the default status not_started.
- Save server.py.
- Restart the Inspector with your existing configuration by running this command:
npx @modelcontextprotocol/inspector@2.16.0 --config inspector-config.json
Why run the Inspector again?
The Inspector launches server.py as a new local process. Relaunching loads the resource code you just saved.
- Connect Inspector to nextwork-demo.
- Choose nextwork-demo from the configured server list.
- Submit the connection request.
- Read nextwork://learner/progress from the Resources view.
- Select Resources.
- Choose nextwork://learner/progress.
- Submit the resource read.
You should see one record per demo project. The static-website record has the status in_progress.
- Stop the Inspector process by pressing Ctrl+C in Terminal.
A prompt packages a reusable request that the user chooses to render. Its goal argument turns one template into a recommendation request for different learning goals.
- Return to the if __name__ == "__main__": guard in server.py.
- Insert the following prompt directly above the guard:
@mcp.prompt(title="Recommend a demo project")
def recommend_next_project(goal: str) -> str:
"""Create a guided request for choosing the next demo project."""
return (
"Use the NextWork Demo MCP server to recommend one project for this goal: "
f"{goal}\n\n"
"Search the catalog, inspect the best match, read "
"nextwork://learner/progress, and explain the recommendation."
)
What does this code do?
- The decorator exposes recommend_next_project as a prompt with a readable title.
- The goal argument becomes part of the rendered request.
- The returned message directs the client to search the catalog before reading saved progress.
- Save server.py.
✔️ Awesome, I've got everything!
Your server.py now contains the write tool, progress resource, and recommendation prompt.
ⓧ I'd like to double check the full code
import json
from pathlib import Path
from mcp.server import MCPServer
from mcp.types import ToolAnnotations
mcp = MCPServer("NextWork Demo")
BASE_DIR = Path(__file__).parent
PROGRESS_FILE = BASE_DIR / "progress.json"
PROJECTS: list[dict[str, str]] = [
{
"id": "static-website",
"title": "Launch a Static Website",
"topic": "cloud",
"difficulty": "easy",
"summary": "Publish a small website and verify that visitors can load it.",
},
{
"id": "container-api",
"title": "Containerize a Small API",
"topic": "containers",
"difficulty": "medium",
"summary": "Package a small service so it runs consistently in a container.",
},
{
"id": "data-dashboard",
"title": "Build a Data Dashboard",
"topic": "data",
"difficulty": "easy",
"summary": "Turn a sample dataset into a simple visual dashboard.",
},
]
def find_project(project_id: str) -> dict[str, str] | None:
for project in PROJECTS:
if project["id"] == project_id:
return project
return None
def load_progress() -> dict[str, str]:
if not PROGRESS_FILE.exists():
return {}
try:
return json.loads(PROGRESS_FILE.read_text(encoding="utf-8"))
except (json.JSONDecodeError, OSError):
return {}
def save_progress(progress: dict[str, str]) -> None:
PROGRESS_FILE.write_text(
json.dumps(progress, indent=2, sort_keys=True),
encoding="utf-8",
)
@mcp.tool(
title="Search demo projects",
annotations=ToolAnnotations(read_only_hint=True, open_world_hint=False),
)
def search_projects(topic: str = "", difficulty: str = "") -> str:
"""Search demo projects by topic and difficulty."""
topic_filter = topic.strip().lower()
difficulty_filter = difficulty.strip().lower()
matches = [
project
for project in PROJECTS
if (
not topic_filter
or topic_filter in project["topic"].lower()
or topic_filter in project["title"].lower()
)
and (
not difficulty_filter
or difficulty_filter == project["difficulty"].lower()
)
]
if not matches:
return "No matching demo projects."
return "\n".join(
f"{project['id']}: {project['title']} "
f"({project['topic']}, {project['difficulty']})"
for project in matches
)
@mcp.tool(
title="Get demo project details",
annotations=ToolAnnotations(read_only_hint=True, open_world_hint=False),
)
def get_project(project_id: str) -> str:
"""Get details and saved status for one demo project."""
project = find_project(project_id)
if project is None:
return f"No demo project has the ID {project_id}."
status = load_progress().get(project_id, "not_started")
return (
f"Title: {project['title']}\n"
f"Topic: {project['topic']}\n"
f"Difficulty: {project['difficulty']}\n"
f"Summary: {project['summary']}\n"
f"Status: {status}"
)
@mcp.tool(
title="Start a demo project",
annotations=ToolAnnotations(
read_only_hint=False,
destructive_hint=False,
idempotent_hint=True,
open_world_hint=False,
),
)
def start_project(project_id: str) -> str:
"""Mark one demo project as in progress."""
project = find_project(project_id)
if project is None:
return f"No demo project has the ID {project_id}."
progress = load_progress()
progress[project_id] = "in_progress"
save_progress(progress)
return f"Started {project['title']}. Saved status: in_progress."
@mcp.resource("nextwork://learner/progress", mime_type="application/json")
def learner_progress() -> str:
"""Current project status for the demo learner."""
progress = load_progress()
payload = [
{
"project_id": project["id"],
"title": project["title"],
"status": progress.get(project["id"], "not_started"),
}
for project in PROJECTS
]
return json.dumps(payload, indent=2)
@mcp.prompt(title="Recommend a demo project")
def recommend_next_project(goal: str) -> str:
"""Create a guided request for choosing the next demo project."""
return (
"Use the NextWork Demo MCP server to recommend one project for this goal: "
f"{goal}\n\n"
"Search the catalog, inspect the best match, read "
"nextwork://learner/progress, and explain the recommendation."
)
if __name__ == "__main__":
mcp.run()
Inspect all three MCP primitives
Tools are model-controlled. Resources are application-controlled. Prompts are user-controlled.
Before you reconnect, which new primitive do you expect the server to advertise alongside its tools?
- Launch the completed server in Inspector by running this command:
npx @modelcontextprotocol/inspector@2.16.0 --config inspector-config.json
Why launch a fresh process?
A fresh Inspector process starts the completed version of server.py. Its discovery requests can now receive the tool, resource, and prompt capabilities.
- Connect Inspector to nextwork-demo.
- Choose nextwork-demo from the configured server list.
- Submit the connection request.
- Call start_project with project_id set to static-website.
- Select Tools.
- Choose start_project.
- Enter static-website in the generated project_id field.
- Submit the tool call.
You should see the saved status remain in_progress. Repeating this tool call produces the same persisted state.
- Read nextwork://learner/progress from the Resources view.
- Select Resources.
- Choose nextwork://learner/progress.
- Submit the resource read.
You should see static-website with the status in_progress alongside the two projects that remain not_started.
- Render recommend_next_project with goal set to learn cloud basics.
- Select Prompts.
- Choose recommend_next_project.
- Enter learn cloud basics in the generated goal field.
- Submit the prompt request.
You should see a rendered message that includes the goal. It directs the client to search before reading nextwork://learner/progress.
- Match the observed discovery requests to the primitive that each request exposes.
- Return to the monitoring view from your earlier Inspector test.
- Locate tools/list plus tools/call.
- Locate resources/list plus resources/read.
- Locate prompts/list plus prompts/get.
The observed requests show that discovery happens before an individual primitive is called or read.
Run the complete Claude Desktop demo
Claude Desktop launches the local server as a subprocess. A full restart replaces the earlier read-only process with the completed version.
- Fully quit Claude Desktop.
- Press Cmd+Q while Claude Desktop is active.
Claude Desktop should close completely.
- Reopen Claude Desktop.
- Press Cmd+Space to open macOS search.
- Type Claude.
- Press Enter.
Claude Desktop should reconnect to nextwork-demo with the completed set of capabilities.
Before you send the request, do you expect Claude to finish after reading the project or call the new write tool as well?
- Ask Claude to complete the full workflow with this prompt:
Find an easy cloud project, start it, and report the saved status
What does this prompt test?
The request requires Claude to search for a match before inspecting its details. Starting the chosen project requires the state-changing tool that was missing earlier.
You should see Claude use search_projects before get_project. It then calls start_project for static-website and reports the saved in_progress status.
- Check the saved status in progress.json.
- Switch back to your existing code editor.
- Select progress.json from the nextwork-mcp-demo project files.
You should see static-website mapped to in_progress. The visible file proves that the state persists outside the model.
- Trace the completed request from the host to the saved local state.
Trace the round trip
Claude Desktop acts as the MCP host. Its embedded MCP client sends the tool request to the local process.
The stdio transport carries the request into the MCP server. The server runs start_project before returning the result through the same route.
You have closed the exact gap exposed in the previous step. Claude can now discover a project and persist its started state.
Secret mission
Enforce a Completion Workflow
A project should only reach completed status after it has been started. Add a guarded completion tool that rejects invalid transitions and saves a valid completion.
Clean Up Your Resources
Clean Up Your Resources
Choose whether to keep your local demo available, pause its running processes, or delete it entirely. Every resource in this project is local, so keeping it creates no usage-based cloud charges.
Resources you used:
- The local nextwork-mcp-demo folder containing every project file.
- The nextwork-demo server entry inside Claude Desktop.
Keep everything running
No action needed. Choose this if you want to keep experimenting with the completed server.
- Keep the nextwork-mcp-demo folder so your completed progress.json state remains available.
- Keep the nextwork-demo configuration entry so Claude Desktop can relaunch the local server.
Pause - I'll come back to this later
Shut down the running applications to free local memory. Your project files remain ready for another session.
- Quit MCP Inspector.
- Fully quit Claude Desktop.
- Return to the active Terminal session.
- Exit the active Python environment by running:
deactivate
What does this command do?
The deactivate command exits the active Python virtual environment while leaving its installed packages in place.
You should see the Terminal prompt stop beginning with (.venv).
Your local files remain unchanged. Claude Desktop can relaunch the server when you return.
Delete - I don't want to use this again
Removing the local demo is permanent. Copy any code or progress you want to keep before continuing.
Remove the Claude Desktop server entry:
- Quit MCP Inspector.
- In Claude Desktop, click Settings.
- Select Developer.
- Click Edit Config.
- In ~/Library/Application Support/Claude/claude_desktop_config.json, remove the complete nextwork-demo entry from mcpServers.
- Keep every other configured server entry unchanged.
- Save claude_desktop_config.json.
Verify the configuration change:
- Fully quit Claude Desktop.
- Start Claude Desktop again through macOS application search.
- Click Add files, connectors, and more.
- Select Connectors.
- Click Manage connectors.
- Confirm that nextwork-demo no longer appears.
Remove the local project folder:
- Return to the Terminal session where .venv is active.
- Exit the active environment by running:
deactivate
What does this command do?
The deactivate command releases the active environment before you remove its folder.
- In Finder, Option-right-click the nextwork-mcp-demo folder.
- Choose Copy “nextwork-mcp-demo” as Pathname.
- Record the copied pathname here: absolute path to nextwork-mcp-demo.
The next command permanently removes the folder at the supplied pathname. The copied pathname keeps the deletion focused on this project.
- Confirm that absolute path to nextwork-mcp-demo ends with /nextwork-mcp-demo.
- Delete the local project folder by running this command:
rm -rf [[PROJECT_PATH="absolute path to nextwork-mcp-demo"]]
What does this command do?
This command permanently removes the project folder at the pathname you supplied. That deletion also removes .venv, server.py, requirements.txt, progress.json, and inspector-config.json.
- Return to Finder.
- Confirm that the nextwork-mcp-demo folder is no longer present at its previous location.
Your local MCP demo and its Claude Desktop registration are now removed.
Nice Work!
Nice Work!
That's your local Model Context Protocol demo complete! Your Python server now works through MCP Inspector plus Claude Desktop.
You've learned how to:
- Trace a request through an MCP host, embedded MCP client, local MCP server, and stdio transport.
- Inspect capability discovery through generated tool schemas. Compare model-controlled tools, application-controlled resources, and user-controlled prompts.
- Use local persistence in progress.json to keep project status outside the model. Read the saved state through learner_progress.
- Complete the optional Secret Mission by adding the guarded complete_project tool. It rejects any project whose load_progress() status is outside in_progress. A valid transition saves completed.
Ready to quiz yourself?