home / mcp / freedanfan mcp server

Freedanfan MCP Server

基于 FastAPI 和 MCP(模型上下文协议),实现 AI 模型与开发环境 之间的标准化上下文交互,提升 AI 应用的可扩展性和可维护性。

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "freedanfan-mcp_server": {
      "command": "python",
      "args": [
        "mcp_server.py"
      ],
      "env": {
        "MCP_SERVER_HOST": "0.0.0.0",
        "MCP_SERVER_PORT": "12000"
      }
    }
  }
}

You can run and interact with this MCP server to enable standardized context communication between AI models and development environments. It provides a JSON-RPC 2.0 API, real-time event notifications via SSE, and a modular, asynchronous Python implementation that makes it easy to deploy, test, and extend in production or development environments.

How to use

You will connect an MCP client to this server to perform initialization, request model-context sampling, and gracefully shut down sessions. Start by launching the server in your environment, then connect your client to the local or remote endpoint. The client will initialize the MCP session, send sampling prompts, and receive structured results including content and usage metrics. Real-time updates are available through SSE for monitoring progress and events.

How to install

# Prerequisites
# Ensure Python 3.8+ and pip are installed

# Clone the project
git clone https://github.com/freedanfan/mcp_server.git
cd mcp_server

# Install dependencies
pip install -r requirements.txt

# Run the server (defaults to 127.0.0.1:12000)
export MCP_SERVER_HOST=0.0.0.0
export MCP_SERVER_PORT=12000
python mcp_server.py

Additional notes

If you want the server accessible at a specific address and port, set the environment variables MCP_SERVER_HOST and MCP_SERVER_PORT before starting the server. The client can point to the server URL using the same host and port configuration.

Troubleshooting

Common issues include connection errors if the server is not running or the client points to the wrong URL, 405 errors if requests are sent to an incorrect endpoint, and SSE connection failures caused by network or firewall settings. Check that the server process is active, verify the host/port values, and ensure network paths allow the required traffic.

Security and best practices

Run the server in a controlled environment, restrict access to trusted clients, and monitor logs for abnormal activity. When exposing the server publicly, consider enabling TLS termination and validating client permissions at the API layer. Regularly update dependencies to mitigate known vulnerabilities.

Tools and capabilities

The MCP server exposes core methods for initialization, sampling, and shutdown, enabling clients to establish a session, request model-context generation, and cleanly terminate sessions. You can extend the server by adding new method handlers that integrate with your AI models and data sources.

Available tools

initialize

Initialize a new MCP session, negotiate capabilities, and establish a communication channel between the client and server.

sample

Submit a sampling request with a prompt and receive generated content along with usage metrics.

shutdown

Terminate the active MCP session gracefully and release resources on the server.