mirror of
https://github.com/Tencent/WeKnora.git
synced 2026-10-30 19:33:05 +08:00
MCP Python SDK 2.0 removed the low-level Server decorator API (@app.list_tools() / @app.call_tool() / app.get_capabilities()), so the server crashed at startup with: AttributeError: 'Server' object has no attribute 'list_tools' The released PyPI package weknora-mcp==1.0.1 declared 'mcp>=1.0.0' with no upper bound, so uvx resolved to the latest 2.0.0 and the plugin's weknora MCP server could no longer connect. Fix: rewrite the server on top of the mcp 2.x high-level MCPServer API (formerly FastMCP), and cap the dependency at 'mcp>=2,<3'. - weknora_mcp_server.py: replace @app.list_tools()/@app.call_tool() with 28 @mcp.tool() function-signature tools (input schema auto-generated from type hints, descriptions from docstrings, plain return values serialized by the framework). Transports use run_stdio_async() / sse_app() / streamable_http_app(). WeKnoraClient business logic is unchanged. - deps: mcp>=2,<3 in pyproject.toml / requirements.txt / setup.py; commit uv.lock pinning mcp 2.0.0. - version bump to 1.1.0 (pyproject, setup, __init__, main --version, server_version). - check_imports.py: validate MCPServer / ToolError / mcp_types imports. - ci(.github/workflows/mcp-server.yml): publish on merge to main + manual dispatch, not only on tags; add PyPI version-dedup check so re-runs on an unchanged version stay green (absorbed from PR #2399). Verified: stdio initialize + tools/list returns all 28 tools; no list_tools AttributeError; tool dispatch + error wrapping confirmed. Co-authored-by: wizardchen <wizardchen@tencent.com>
71 lines
2.2 KiB
Python
71 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
WeKnora MCP Server 安装脚本
|
|
"""
|
|
|
|
from setuptools import setup
|
|
|
|
|
|
# 读取 README 文件
|
|
def read_readme():
|
|
try:
|
|
with open("README.md", "r", encoding="utf-8") as f:
|
|
return f.read()
|
|
except FileNotFoundError:
|
|
return "WeKnora MCP Server - Model Context Protocol server for WeKnora API"
|
|
|
|
|
|
# 读取依赖
|
|
def read_requirements():
|
|
try:
|
|
with open("requirements.txt", "r", encoding="utf-8") as f:
|
|
return [
|
|
line.strip() for line in f if line.strip() and not line.startswith("#")
|
|
]
|
|
except FileNotFoundError:
|
|
return [
|
|
"mcp>=2,<3",
|
|
"requests>=2.31.0",
|
|
"starlette>=0.27.0",
|
|
"uvicorn>=0.24.0",
|
|
]
|
|
|
|
|
|
setup(
|
|
name="weknora-mcp",
|
|
version="1.1.0",
|
|
author="WeKnora Team",
|
|
author_email="support@weknora.com",
|
|
description="WeKnora MCP Server - Model Context Protocol server for WeKnora API",
|
|
long_description=read_readme(),
|
|
long_description_content_type="text/markdown",
|
|
url="https://github.com/NannaOlympicBroadcast/WeKnoraMCP",
|
|
py_modules=["weknora_mcp_server", "upload_paths", "main", "run_server", "run", "test_module"],
|
|
classifiers=[
|
|
"Development Status :: 4 - Beta",
|
|
"Intended Audience :: Developers",
|
|
"License :: OSI Approved :: MIT License",
|
|
"Operating System :: OS Independent",
|
|
"Programming Language :: Python :: 3",
|
|
"Programming Language :: Python :: 3.10",
|
|
"Programming Language :: Python :: 3.11",
|
|
"Programming Language :: Python :: 3.12",
|
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
"Topic :: Internet :: WWW/HTTP :: HTTP Servers",
|
|
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
],
|
|
python_requires=">=3.10",
|
|
install_requires=read_requirements(),
|
|
entry_points={
|
|
"console_scripts": [
|
|
"weknora-mcp-server=main:sync_main",
|
|
"weknora-server=run_server:main",
|
|
],
|
|
},
|
|
include_package_data=True,
|
|
data_files=[
|
|
("", ["README.md", "requirements.txt", "LICENSE"]),
|
|
],
|
|
keywords="mcp model-context-protocol weknora knowledge-management api-server",
|
|
)
|