Let's Talk AI MCP,Uncategorized How to Vibe Build and Run Your Own MCP Server with Claude and Cursor

How to Vibe Build and Run Your Own MCP Server with Claude and Cursor

  • MCP (Model Context Protocol): Unlocking Safe AI Integration

MCP (Model Context Protocol) is an emerging standard that enables AI models (such as ChatGPT, Claude, Gemini, and others) to safely, securely, and systematically connect to your software applications, APIs, databases, or documents.

MCP allows AI models to interact with live data, including inventories, support tickets, documentation, and pricing, without needing custom integrations or exposing sensitive infrastructure. This results in faster AI-driven automation, smarter virtual assistants, and greater ROI. For instance, MCP enables an AI assistant to instantly respond to customer queries using your internal documentation without sending your content to external servers.

Designed with clear permissions and robust isolation:

  • Precisely control what data the AI can access and how it can be used.
  • Ensure data never leaves your environment unless explicitly authorized.

This makes MCP especially suitable for regulated industries such as finance, legal, and healthcare. As AI-powered agents and copilots become more prevalent, MCP is rapidly becoming the expected standard interface.

 

Step-by-Step Guide to Setting Up an MCP Server

0. Important Considerations

a. Security

MCP is powerful and unlocks significant potential due to widespread acceptance and availability of numerous prebuilt MCP servers online (e.g., GitHub). However, exercise caution with external resources, especially when running MCP servers locally.

Example repositories:

Inspired by Eden Marco’s MCP Course (Udemy), this guide adopts a “vibe coding” approach to create a weather MCP Server

b. GitHub files

You can find all my final files from this step-by-step here: https://github.com/jsyssauw/library/tree/main/MCP/WeatherMCP

1. Prerequisites

  • Python 3.10+ installed.
  • Claude Desktop or another MCP-compatible client (any plan works).
  • MCP SDK (Python package).
  • Cursor IDE (recommended) or code generation via ChatGPT/Claude.
  • Conda (or alternative like virtualenv or uv) to manage Python environments.

2. Project Environment Setup

a. Create project directory:

mkdir weatherMCP
cd weatherMCP

b. Create and activate virtual environment:
Update Conda first:

conda update -n base -c defaults conda

Create the virtual environment:

conda create --name weatherMCP python=3.13
conda activate weatherMCP

c. Install necessary packages:

pip install mcp mcp[cli] httpx

3. Vibe Coding the MCP Server

a. Launch Cursor IDE:

cursor .

b. Configure Cursor for optimal context:

  • Go to Files > Preferences > Cursor Settings > Features
  • Add MCP documentation as context for the cursor agent:

c. Configure Cursor Rules for Quality Python Code:

  • Create directories: .cursor/rules within your main project directory.
  • Add a rule file (python.mdc) from Cursor Rules, ideally using Caio Barbieri’s rules for Python, FastAPI, and scalable API development. 
  • Set the rule type to “Always.”. These rules are now always send along when a request is made to the LLM.

d. Generate MCP Server Code:

  • Set Cursor agent to “Agent Mode” (e.g. use Claude 3.7-sonnet).
  • Use a prompt alike:  Create a python script that runs a MCP server @MCP. Use the python SDK @MCP Python SDK. The server should expose 2 tools which are called get_alerts and get_forecast from the api @https://api.weather.gov. Keep it simple.
  • Ensure these files are generated:
    • weather-server.py
    • README.md
    • requirements.txt
  • If missing files, ask the agent explicitly to create them.
  • I asked the agent to update the weather_server.py file to include some text output with relevant runtime information to indicate when the MCP server was running in a python env.

e. Test your setup:

conda activate weatherMCP
python weather_server.py

4. Connecting MCP Server to Claude Desktop

  • Open Claude Desktop → File > Settings > Developer

  • Click “Edit Config” to modify claude_desktop_config.json

  • As the file is not part of the current directory, I had some issue with my cursor setup; my agent didn’t update my claude_desktop_config.json file directly. To keep things simple I simply asked the agent to generate the code for me to copy and paste it in the file

    • In the cursor agent panel “Change the current claude_desktop_config.json with this content [copy_content] to include the new weather_server.py MCP Service”

    • copy and paste the content in the claude_desktop_config.json and save

  • Stop Claude (fully via task manager if needed), then restart.

  • Verify MCP server availability by toggling the new tools from Claude’s interface (click on the switches icon next to the + icon under the chat panel.

Troubleshooting (Common Error):

  • DEBUG: I received an error when following this procedure. After debugging and looking in the mcp-server-weather.log, it was clear that we missed the the httpx package. However we installed as seen above. The logical conclusion was that the python code was not executed in the correct environment. Investigating the claude_desktop_config.json revealed that the command use was “python.exe”, which is starting python in the default env. Changing this to the right directory solved the issue.

"command": "D:\\Programs\\anaconda3\\envs\\weatherMCP\\python.exe"

  • Save the claude_desktop_config.json file with the change and completely restart Claude Desktop solved the issue
  • Restart Claude fully after making changes.

5. Testing the Integration

  • Start Claude Desktop and test by asking:

    “What is the weather like in Celsius and wind speed in km/h in SFO today and tomorrow?”

If correctly configured, your MCP server will provide accurate, integrated results seamlessly.

 

Receive Latest Updates!

We don’t spam! Read our privacy policy for more info.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post