MCP ExplorerExplorer

Simple Mcp Server

@marlinspikeon 10 months ago
2 MIT
FreeCommunity
AI Systems
A simple MCP server that can be tested with a client

Overview

What is Simple Mcp Server

Simple-MCP-Server is a straightforward implementation of an MCP server designed for testing MCP clients. It provides a basic framework to interact with various tools, such as weather information and note-keeping functionalities.

Use cases

Use cases for Simple-MCP-Server include testing weather API integrations, managing notes through a simple interface, and experimenting with AI agents to enhance user interactions and automate tasks.

How to use

To use Simple-MCP-Server, clone the repository, navigate to the project directory, install the required dependencies, and set up a .env file with necessary API keys. You can then run the server and access it via a web browser to test different functionalities.

Key features

Key features of Simple-MCP-Server include the ability to test multiple tools like weather queries and note management, a user-friendly interface for interaction, and support for integration with OpenAI agents for enhanced functionalities.

Where to use

Simple-MCP-Server can be utilized in various fields such as software development for testing client-server interactions, educational purposes for learning about MCP protocols, and in research for developing and testing AI agents.

Content

MCP SimpleServer

A simple example of an MCP Server that can be used to test MCP clients.

Usage

  1. Clone the repository:
    git clone

  2. Navigate to the project directory:
    cd simpleserver

  3. Install the required dependencies:
    uv sync if you have uv installed, or
    pip install -r requirements.txt if you’re using pip. I strongly recommend using uv as it is faster and more efficient, and it’s required for the commands below.

  4. Create a .env file in the root of the project and add the following Keys (see .env.example):

WEATHER_API_KEY=xxx
OPENAI_API_KEY=sk-
NOTES_FILE="/tmp/notes.md"

You can get a free OpenWeatherMap API key from https://openweathermap.org/api and an OpenAI API key from https://platform.openai.com/signup.

Testing a Weather MCP Server (main.py)

  1. Run the server:
    uv run mcp dev main.py
    This will start the server, and you can browse to it at localhost (default port is 6274)
  2. Open a browser to http://127.0.0.1:6274
  3. Click “Connect”
  4. Click “Tools” in the top menu
  5. Click “List Tools”

You should now see two methods, “add” and “get_weather”.

  1. Click “get_weather”, and enter the name of a city (e.g., “London”) in the input field.
  2. Click “Run Tool”. If you’ve got a Weather API key set up, you should see the weather for that city.

Testing a Note Keeper (simplenote.py)

  1. Run the server:
    uv run mcp dev simplenote.py
    This will start the server, and you can browse to it at localhost (default port is 6274)
  2. Open a browser to http://localhost:6274
  3. Click “Connect”
  4. Click “Tools” in the top menu
  5. Click “List Tools”
    You should now see two methods, “add_note”, “get_notes” and “get_last_note”.

You can use these commands to Add a note, Get all Notes, or get just the last note. Entries will persist, as they’re saved to a local file.

Testing the MCP Server with an OpenAI Agent (aiagent.py)

MCP really shines when it’s used with an OpenAI Agent. You can chat with an OpenAI Model, and have it call the MCP Server to get information and perform custom actions.
Run the app: uv run aiagent.py

Chat away! It will call the MCP Server when you ask it to perform actions that are defined in the MCP Server:
- Add a note
- Get all notes
- Get the last note

How MCP with an Agent works

  • Loads environment variables (including your OpenAI API key) from a .env file.
  • Starts the SimpleNotes MCP server as a subprocess.
  • Creates an Agent with instructions to handle both note management and general queries.
  • Runs an interactive chat loop:
  • Prompts the user for input.
  • Sends the input to the agent, which uses the MCP server and OpenAI model to generate a response.
  • Prints the assistant’s reply.
  • Handles graceful exit on “quit”, Ctrl+C, or EOF.

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers