Title: Lab 10 — Build and Verify an MCP Server for Your Capstone
Course: AIINFRA 303: Capstone Project > Section: Week 10 — Adding Agentic and MCP or Retrieval Capabilities

🛠️ Lab 10 — Build and Verify an MCP Server for Your Capstone (50 pts)

Goal: Expose one real capability of your capstone project (a query against your API, database, or another data source) as an MCP tool, using only free and open-source tools, and prove it works by testing it in the standalone MCP Inspector. Steps:

1. Set up your environment. In your capstone project's repo, create a new folder (e.g., mcp_server/) and install the MCP Python SDK: pip install "mcp[cli]" (or add it to your existing project's dependency file). Confirm you have Node.js available for npx — the Inspector needs it.
2. Follow the official "Build an MCP server" tutorial (linked in Resources) to scaffold a minimal FastMCP server, so you start from a known-working structure rather than guessing at the API.
3. Adapt the example to your capstone. Replace the tutorial's example tool with one meaningful to your own project — for example, a tool that queries your capstone's database, calls your capstone's own API endpoint, or looks up a record you already have from an earlier week. Use the @mcp.tool() decorator, give the tool a clear name and docstring (the docstring is what the agent sees when deciding whether to call it), and use type-annotated parameters.
4. Run the server over stdio transport locally, exactly as shown in the tutorial.
5. Test it interactively with the MCP Inspector by running npx @modelcontextprotocol/inspector pointed at your server. Confirm the Inspector lists your tool correctly, then invoke it with at least two different sets of parameters (one valid, one edge case) and confirm the results look correct.
6. Add one guardrail. Based on this week's lecture, add at least one input validation check or safety limit to your tool (e.g., reject an out-of-range parameter, cap the number of rows returned, refuse a write operation). Note in your writeup what could go wrong without it.
7. (Stretch, not required for full credit) Connect it to a client. If time allows, connect your server to an MCP host/client (e.g., Claude Desktop's MCP config, or a small script using the MCP client SDK) and confirm an LLM agent can actually invoke the tool in conversation, not just in the Inspector.
8. Write a short lab report (half a page to one page) describing: what your tool does, why it's relevant to your capstone, the guardrail you added, and one thing you observed while testing in the Inspector that surprised you.

Deliverables: Your MCP server source code (e.g., server.py), a screenshot or text export of the MCP Inspector session showing your tool listed and successfully invoked, and your short lab report, all submitted together (zip, repo link, or pasted text).