The mcp - client
project is designed to expose a local MCP server using Flask, enabling users to set up their own intranet penetration. This allows platforms like Coze, Dify, and FastGPT to interact with local resources seamlessly.
Ensure that the uv
tool is installed. Refer to the official documentation for installation instructions.
Create a new directory for the project and navigate into it:
uv init project - name
cd project - name
Replace project - name
with your desired project name.
Create and activate a virtual environment using uv
:
uv venv
.venv\Scripts\activate
For Linux or macOS:
source .venv/bin/activate
Install the project dependencies listed in pyproject.toml
:
uv install
Configure server details in mcp_server.json
. Example configuration:
{
"mcpServers": {
"weather": {
"desc": "获取天气信息以及相关工具",
"command": "uv",
"args": [
"--directory",
"D:\\project_python\\MCP\\weather",
"run",
"weather.py"
]
},
"filesystem": {
"desc": "文件管理",
"command": "uv",
"args": [
"--directory",
"D:\\project_python\\MCP\\mcp - server\\filesystem",
"run",
"main.py"
]
}
}
}
Copy .env.example
to .env
:
cp .env.example .env
Fill in the environment variables in .env
:
ANTHROPIC_API_KEY = 123456
SECRET_KEY = gduifgashjb8t3961jhgsdghf
Ensure .env
is in .gitignore
:
.env
Start the server by running:
python server.py
Send a POST request to /list_tool
:
{
"server_name": "weather",
"secret_key": "gduifgashjb8t3961jhgsdghf"
}
Send a POST request to /call_tool
:
{
"server_name": "weather",
"tool_name": "get_weather",
"args": {
"city": "Beijing"
},
"secret_key": "gduifgashjb8t3961jhgsdghf"
}
Send a POST request to /list_server
:
{
"secret_key": "gduifgashjb8t3961jhgsdghf"
}
Send a POST request to /list_files
:
{
"secret_key": "gduifgashjb8t3961jhgsdghf"
}
Send a GET request to /get_download_link/<secret_key>/<filename>
:
curl http://localhost:5000/get_download_link/gduifgashjb8t3961jhgsdghf/example.txt
Ensure paths and commands in mcp_server.json
are correct to avoid service startup issues.
Keep .env
secure to prevent leakage of sensitive information like API keys.
Use app.run(debug = True, ssl_context = 'adhoc')
for development. Avoid using debug mode in production.
Self-signed certificates may cause issues on cloud platforms like Coze. Consider using a trusted SSL certificate for deployment.