MCP

MCP

By edonyzpc GitHub

Personal MCP Server for LLM

Overview

what is MCP?

MCP is a personal server and client system designed for Large Language Models (LLMs), enabling users to set up their own servers and clients for various applications, such as weather data retrieval.

how to use MCP?

To use MCP, initialize the project with the provided commands, set up a Python virtual environment, install the necessary dependencies, and run the server and client scripts to interact with the LLM.

key features of MCP?

  • Personal server and client setup for LLMs
  • Weather service integration for US weather data
  • Easy project initialization and dependency management

use cases of MCP?

  1. Setting up a personal weather data server using LLMs.
  2. Creating custom clients to interact with various LLM services.
  3. Developing and testing LLM applications in a controlled environment.

FAQ from MCP?

  • Can MCP be used for other services besides weather?

Yes! MCP can be adapted for various services by modifying the server and client configurations.

  • Is MCP easy to set up?

Yes! The setup process is straightforward with clear instructions provided in the documentation.

  • What programming language is MCP built with?

MCP is built using Python.

Content

MCP

Personal MCP Servers and Clients for LLM

Setup

  1. init the project with uv
uv init --python=3.10 .
touch .gitignore .env
cat << EOF >> .gitignore
.env
.venv/
__pycache__/
EOF
  1. init python virtual environment
uv venv
source .venv/bin/activate
  1. install dependencies
uv add dashscope httpx mcp python-dotenv langchain langchain-core langchain-mcp-adapters langchain-community langgraph

MCP Server

MCP Server Weather

This is the MCP server for the Weather service to get US weather data.

Project

# Create a new directory for our project
mkdir -p servers/weather-server-mcp

# Create virtual environment and activate it
uv venv
source .venv/bin/activate

# Create our server file
cd servers/weather-server-mcp
touch weather.py

Run

  1. Copy the server configuration file from the MCP Host, e.g. OpenCat
  2. Select the tool of this MCP server(weather)
  3. Chat in the Host, e.g. OpenCat

MCP Client

MCP Client for Weather Server

This is the MCP client for the Weather service to get US weather data.

Project

# Create project directory
mkdir -p clients/mcp-client

# Create virtual environment
uv venv
# Activate virtual environment
source .venv/bin/activate

# Create our main file
cd clients/mcp-client
touch clients/mcp-client/client.py

Run

# to run the client which is connected to the weather mcp server
uv run ./clients/mcp-client/client.py ./servers/weather-server-mcp/weather.py

Inspect MCP Server

npx @modelcontextprotocol/inspector \
  uv \
  --directory servers/weather-server-mcp \
  run \
  weather.py

No tools information available.
No content found.