WeKnora/mcp-server/pyproject.toml

108 lines
2.8 KiB
TOML
Raw Normal View History

2025-09-08 05:14:35 +00:00
[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.2"]
build-backend = "setuptools.build_meta"
[project]
fix(mcp-server): route diagnostics to stderr to fix stdio protocol crash (#2371) * fix(mcp-server): route diagnostics to stderr to fix stdio protocol crash Entry scripts (run_server.py, main.py, run.py) printed diagnostics to stdout via bare print(). Under the stdio transport (the default and the path used by all MCP clients per MCP_CONFIG.md: `uv run run_server.py`), stdout is the JSON-RPC channel, so the plain-text lines emitted before the initialize handshake corrupted the protocol stream. Strict MCP clients (Claude Desktop / Cursor / ZCode / VS Code Copilot) treated this as a fatal protocol error and reported the server as failed-to-start. Redirect all diagnostic print() to sys.stderr (per MCP spec, only JSON-RPC may use stdout). weknora_mcp_server.py already routes through logging (stderr) and is unchanged. Verified against a live backend (initialize -> tools/list (28 tools) -> tools/call list_knowledge_bases); stdout first byte is now '{' with all diagnostics on stderr. * chore(mcp-server): publish package name as weknora-mcp Rename the PyPI distribution name from weknora-mcp-server to weknora-mcp (tools used: pyproject [project].name + setup.py name). The installed console-script commands (weknora-mcp-server, weknora-server) and the Python module (weknora_mcp_server) are unchanged for backward compatibility. * fix(mcp-server): include upload_paths in wheel + bump to 1.0.1 The 1.0.0 wheel was missing upload_paths.py: it was absent from the [tool.setuptools] py-modules list (and setup.py py_modules), so setuptools never packed it. weknora_mcp_server.py line 26 does `from upload_paths import resolve_upload_file_path, set_active_transport`, so any path that fully imports the module — i.e. the MCP client initialize handshake — crashed with ModuleNotFoundError. `--version` survived only because argparse exits before that import runs. Fix: add 'upload_paths' to py-modules (pyproject.toml + setup.py) and bump to 1.0.1 (1.0.0 is immutable on PyPI). Also sync the user-facing version strings (__version__, server_version, main --version) to 1.0.1. * ci(mcp-server): add workflow.yml to build & publish to PyPI via OIDC Adds .github/workflows/workflow.yml adapted from annopick/tuomin's ci.yml: - test: matrix Python 3.10–3.13 (matches requires-python >=3.10), runs the flat test_*.py suite in mcp-server/ - build: on mcp-server-v* tags, builds sdist + wheel via uv build, and guards against the 1.0.0 regression by asserting upload_paths.py is in the wheel before publishing - publish: PyPI Trusted Publishing (OIDC, id-token: write) to weknora-mcp, no API token needed Publishing is gated on tags named mcp-server-v* to decouple from the Go release workflow that already targets v* tags. * fix(mcp-server): route diagnostics to stderr and fix packaging/CI Prevent MCP stdio startup crashes by sending entry-script diagnostics to stderr, package upload_paths in the wheel, and add unittest-based CI with stdout purity regression tests. --------- Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-07-28 13:23:09 +00:00
name = "weknora-mcp"
fix(mcp-server): migrate to MCPServer high-level API (mcp 2.x) [v1.1.0] 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>
2026-07-30 06:44:25 +00:00
version = "1.1.0"
2025-09-08 05:14:35 +00:00
description = "WeKnora MCP Server - Model Context Protocol server for WeKnora API"
readme = "README.md"
license = {text = "MIT"}
authors = [
{name = "WeKnora Team", email = "support@weknora.com"}
]
maintainers = [
{name = "WeKnora Team", email = "support@weknora.com"}
]
keywords = ["mcp", "model-context-protocol", "weknora", "knowledge-management", "api-server"]
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",
]
2025-10-30 08:00:28 +00:00
requires-python = ">=3.10"
2025-09-08 05:14:35 +00:00
dependencies = [
fix(mcp-server): migrate to MCPServer high-level API (mcp 2.x) [v1.1.0] 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>
2026-07-30 06:44:25 +00:00
"mcp>=2,<3",
2025-09-08 05:14:35 +00:00
"requests>=2.31.0",
"starlette>=0.27.0",
"uvicorn>=0.24.0",
2025-09-08 05:14:35 +00:00
]
[project.optional-dependencies]
dev = [
"pytest>=7.0",
"pytest-asyncio>=0.21.0",
"black>=23.0",
"flake8>=6.0",
"mypy>=1.0",
]
test = [
"pytest>=7.0",
"pytest-asyncio>=0.21.0",
"pytest-cov>=4.0",
]
[project.urls]
Homepage = "https://github.com/NannaOlympicBroadcast/WeKnoraMCP"
Documentation = "https://docs.weknora.com"
Repository = "https://github.com/NannaOlympicBroadcast/WeKnoraMCP"
"Bug Reports" = "https://github.com/NannaOlympicBroadcast/WeKnoraMCP/issues"
Changelog = "https://github.com/NannaOlympicBroadcast/WeKnoraMCP/blob/main/CHANGELOG.md"
[project.scripts]
weknora-mcp-server = "main:sync_main"
weknora-server = "run_server:main"
[tool.setuptools]
fix(mcp-server): route diagnostics to stderr to fix stdio protocol crash (#2371) * fix(mcp-server): route diagnostics to stderr to fix stdio protocol crash Entry scripts (run_server.py, main.py, run.py) printed diagnostics to stdout via bare print(). Under the stdio transport (the default and the path used by all MCP clients per MCP_CONFIG.md: `uv run run_server.py`), stdout is the JSON-RPC channel, so the plain-text lines emitted before the initialize handshake corrupted the protocol stream. Strict MCP clients (Claude Desktop / Cursor / ZCode / VS Code Copilot) treated this as a fatal protocol error and reported the server as failed-to-start. Redirect all diagnostic print() to sys.stderr (per MCP spec, only JSON-RPC may use stdout). weknora_mcp_server.py already routes through logging (stderr) and is unchanged. Verified against a live backend (initialize -> tools/list (28 tools) -> tools/call list_knowledge_bases); stdout first byte is now '{' with all diagnostics on stderr. * chore(mcp-server): publish package name as weknora-mcp Rename the PyPI distribution name from weknora-mcp-server to weknora-mcp (tools used: pyproject [project].name + setup.py name). The installed console-script commands (weknora-mcp-server, weknora-server) and the Python module (weknora_mcp_server) are unchanged for backward compatibility. * fix(mcp-server): include upload_paths in wheel + bump to 1.0.1 The 1.0.0 wheel was missing upload_paths.py: it was absent from the [tool.setuptools] py-modules list (and setup.py py_modules), so setuptools never packed it. weknora_mcp_server.py line 26 does `from upload_paths import resolve_upload_file_path, set_active_transport`, so any path that fully imports the module — i.e. the MCP client initialize handshake — crashed with ModuleNotFoundError. `--version` survived only because argparse exits before that import runs. Fix: add 'upload_paths' to py-modules (pyproject.toml + setup.py) and bump to 1.0.1 (1.0.0 is immutable on PyPI). Also sync the user-facing version strings (__version__, server_version, main --version) to 1.0.1. * ci(mcp-server): add workflow.yml to build & publish to PyPI via OIDC Adds .github/workflows/workflow.yml adapted from annopick/tuomin's ci.yml: - test: matrix Python 3.10–3.13 (matches requires-python >=3.10), runs the flat test_*.py suite in mcp-server/ - build: on mcp-server-v* tags, builds sdist + wheel via uv build, and guards against the 1.0.0 regression by asserting upload_paths.py is in the wheel before publishing - publish: PyPI Trusted Publishing (OIDC, id-token: write) to weknora-mcp, no API token needed Publishing is gated on tags named mcp-server-v* to decouple from the Go release workflow that already targets v* tags. * fix(mcp-server): route diagnostics to stderr and fix packaging/CI Prevent MCP stdio startup crashes by sending entry-script diagnostics to stderr, package upload_paths in the wheel, and add unittest-based CI with stdout purity regression tests. --------- Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-07-28 13:23:09 +00:00
py-modules = ["weknora_mcp_server", "upload_paths", "main", "run_server", "run", "test_module"]
2025-09-08 05:14:35 +00:00
include-package-data = true
[tool.setuptools.package-data]
"*" = ["*.md", "*.txt", "*.yml", "*.yaml"]
[tool.black]
line-length = 88
target-version = ['py38']
include = '\.pyi?$'
extend-exclude = '''
/(
# directories
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| build
| dist
)/
'''
[tool.mypy]
python_version = "3.8"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
check_untyped_defs = true
disallow_untyped_decorators = true
no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_no_return = true
warn_unreachable = true
strict_equality = true
[tool.pytest.ini_options]
minversion = "7.0"
addopts = "-ra -q --strict-markers --strict-config"
testpaths = ["tests"]
asyncio_mode = "auto"