Skip to main content
Glama
lokesh1382

MCP Products Server

by lokesh1382
README.md
# šŸ›’ MCP Products Server

A hands-on Python project demonstrating **Model Context Protocol (MCP)** by building a product management server that integrates with Claude Desktop and GitHub Copilot.



## šŸ—‚ļø Project Structure

```
create_new_mcp/
│
ā”œā”€ā”€ mcp_server.py        # MCP Server with tools, resource, and prompt template
ā”œā”€ā”€ add_product.py       # DB logic to INSERT a product
ā”œā”€ā”€ fetch_products.py    # DB logic to SELECT all products
ā”œā”€ā”€ db_connect.py        # Database connection helper
ā”œā”€ā”€ .env                 # API keys and DB credentials (not committed)
ā”œā”€ā”€ .gitignore
└── README.md
```

---

## āš™ļø MCP Server — `mcp_server.py`



## šŸ”Œ Configuration

### Claude Desktop
Update `claude_desktop_config.json`:
```json
{
  "mcpServers": {
    "products": {
      "command": "uv.exe",
      "args": [
        "--directory", "C:\\path\\to\\create_new_mcp",
        "run", "mcp_server.py"
      ]
    }
  }
}
```

### GitHub Copilot
Update `mcp.json` with the same server details.


## šŸš€ Getting Started

### Prerequisites
- Python 3.10+
- `uv` package manager
- MySQL database
- Claude Desktop or GitHub Copilot


## šŸ“š Key Learnings

- āœ… MCP Tools are invoked directly by the LLM
- āœ… MCP Resources are fetched manually via host UI and injected into context
- āœ… Prompt Templates enable consistent prompt generation via `/` command
- āš ļø MCP Sampling (server → LLM callback) is **not yet supported** by Claude Desktop or GitHub Copilot in practice
- šŸ’” Workaround for sampling: call Anthropic API directly from the MCP server