MCP Python Server - Streamable HTTP

MCP Python Server - Streamable HTTP

Enables AI assistants to execute Python functions and system commands via Streamable HTTP, including bash, Python code execution, file operations, and text searching.

Category
Visit Server

README

MCP Python Server - Streamable HTTP

A simple Model Context Protocol (MCP) server built using FastMCP that exposes multiple tools over Streamable HTTP. This project demonstrates how AI assistants (such as Claude Desktop, LangChain Agents, Cursor, or any MCP-compatible client) can discover and execute Python functions as tools.


Features

  • Streamable HTTP transport
  • Automatic tool discovery
  • Execute Bash commands
  • Execute Python code
  • Execute Python files
  • Read and write files
  • Search files using glob patterns
  • Search text inside files
  • Create and delete folders

Project Structure

.
├── server.py          # Starts the MCP HTTP Server
├── tools.py           # Tool definitions exposed to MCP clients
├── requirements.txt
├── README.md
└── .gitignore

Available Tools

bash(command: str)

Executes a Bash/Command Prompt command and returns the output.

Example:

bash("dir")

python_code(code: str)

Executes Python code directly.

Example:

python_code("print('Hello MCP')")

python_file(file: str)

Runs a Python script.

Example:

python_file("sample.py")

glob(pattern: str)

Returns files matching a pattern.

Example:

glob("*.py")

grep(pattern: str, file: str)

Searches for matching text inside a file.

Example:

grep("TODO", "notes.txt")

read_file(file: str)

Reads the contents of a file.


write_file(file: str, content: str)

Creates or overwrites a file with the provided content.


create_folder(folder: str)

Creates a directory.


delete_folder(folder: str)

Deletes an existing directory.


Installation

Clone the repository:

git clone https://github.com/nik-red/MCP.git
cd MCP

Create a virtual environment:

Windows

python -m venv .venv
.venv\Scripts\activate

Linux / macOS

python3 -m venv .venv
source .venv/bin/activate

Install dependencies:

pip install -r requirements.txt

Running the Server

Start the MCP server:

python server.py

The server starts using Streamable HTTP on:

http://localhost:8050

Testing with MCP Inspector

Install MCP Inspector (if not already installed):

npx @modelcontextprotocol/inspector

Connect to:

http://localhost:8050

You can:

  • Discover available tools
  • Execute tools interactively
  • Inspect requests and responses
  • Verify tool metadata

How It Works

  1. The server starts and registers all functions decorated with @mcp.tool().
  2. An MCP client connects using the Streamable HTTP protocol.
  3. The client requests the list of available tools.
  4. FastMCP automatically generates tool metadata from the Python function signatures and docstrings.
  5. When a tool is invoked, FastMCP executes the corresponding Python function and returns the result to the client.

Technologies Used

  • Python 3.x
  • FastMCP
  • Model Context Protocol (MCP)
  • Streamable HTTP

Learning Objectives

This project demonstrates:

  • Building an MCP Server
  • Creating custom MCP tools
  • Tool discovery
  • Streamable HTTP transport
  • Function execution through MCP
  • Integrating AI agents with Python applications

Future Improvements

  • Add authentication
  • Restrict dangerous shell commands
  • Add logging
  • Improve error handling
  • Deploy as a Databricks App or Docker container
  • Add Databricks, Azure, and SQL tools
  • Package and publish reusable tools to PyPI

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured