WeKnora deployment source with the reviewed wiki identity, summary and recovery fixes
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,166 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Regression tests for MCP 2.x transport compatibility."""
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import threading
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
MCP_SERVER_DIR = Path(__file__).resolve().parent
|
||||
|
||||
|
||||
class TransportRegressionTest(unittest.TestCase):
|
||||
def test_http_transport_is_stateless(self):
|
||||
import weknora_mcp_server as srv
|
||||
from mcp.server import MCPServer
|
||||
|
||||
probe = MCPServer("probe")
|
||||
probe.streamable_http_app(
|
||||
host="127.0.0.1", stateless_http=srv.STREAMABLE_HTTP_STATELESS
|
||||
)
|
||||
self.assertTrue(probe.session_manager.stateless)
|
||||
|
||||
def test_sse_message_path_matches_legacy_mount(self):
|
||||
import weknora_mcp_server as srv
|
||||
from mcp.server import MCPServer
|
||||
from starlette.routing import Mount, Route
|
||||
|
||||
probe = MCPServer("probe")
|
||||
app = probe.sse_app(host="127.0.0.1", message_path=srv.SSE_MESSAGE_PATH)
|
||||
mount_paths = [
|
||||
route.path
|
||||
for route in app.routes
|
||||
if isinstance(route, (Mount, Route))
|
||||
]
|
||||
self.assertIn("/sse", mount_paths)
|
||||
self.assertIn(
|
||||
srv.SSE_MESSAGE_PATH.rstrip("/"),
|
||||
{path.rstrip("/") for path in mount_paths},
|
||||
)
|
||||
|
||||
def test_weknora_client_session_is_thread_local(self):
|
||||
from weknora_mcp_server import WeKnoraClient
|
||||
|
||||
client = WeKnoraClient("http://localhost:8080/api/v1", "test-key")
|
||||
barrier = threading.Barrier(2)
|
||||
sessions: dict[str, object] = {}
|
||||
|
||||
def worker(name: str) -> None:
|
||||
barrier.wait()
|
||||
sessions[name] = client.session
|
||||
|
||||
threads = [
|
||||
threading.Thread(target=worker, args=(name,))
|
||||
for name in ("a", "b")
|
||||
]
|
||||
for thread in threads:
|
||||
thread.start()
|
||||
for thread in threads:
|
||||
thread.join()
|
||||
|
||||
self.assertEqual(len(sessions), 2)
|
||||
self.assertIsNot(sessions["a"], sessions["b"])
|
||||
|
||||
|
||||
class StdioToolsListTest(unittest.TestCase):
|
||||
def test_tools_list_returns_30_tools(self):
|
||||
async def _run() -> int:
|
||||
from mcp import ClientSession, StdioServerParameters
|
||||
from mcp.client.stdio import stdio_client
|
||||
|
||||
params = StdioServerParameters(
|
||||
command=sys.executable,
|
||||
args=[str(MCP_SERVER_DIR / "weknora_mcp_server.py")],
|
||||
env={
|
||||
**os.environ,
|
||||
"WEKNORA_API_KEY": "test-key",
|
||||
},
|
||||
)
|
||||
async with stdio_client(params) as (read, write):
|
||||
async with ClientSession(read, write) as session:
|
||||
await session.initialize()
|
||||
tools = await session.list_tools()
|
||||
return len(tools.tools)
|
||||
|
||||
count = asyncio.run(_run())
|
||||
self.assertEqual(count, 30)
|
||||
|
||||
|
||||
class HttpStatelessSmokeTest(unittest.TestCase):
|
||||
def test_initialize_does_not_require_mcp_session_id(self):
|
||||
import time
|
||||
|
||||
port = 19876
|
||||
env = {
|
||||
**os.environ,
|
||||
"MCP_SERVER_AUTH_TOKEN": "test-token",
|
||||
"WEKNORA_API_KEY": "test-key",
|
||||
}
|
||||
proc = subprocess.Popen(
|
||||
[
|
||||
sys.executable,
|
||||
"weknora_mcp_server.py",
|
||||
"--transport",
|
||||
"http",
|
||||
"--host",
|
||||
"127.0.0.1",
|
||||
"--port",
|
||||
str(port),
|
||||
],
|
||||
cwd=MCP_SERVER_DIR,
|
||||
env=env,
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL,
|
||||
)
|
||||
try:
|
||||
deadline = time.time() + 10
|
||||
while time.time() < deadline:
|
||||
probe = subprocess.run(
|
||||
[
|
||||
"curl",
|
||||
"-s",
|
||||
"-D",
|
||||
"-",
|
||||
"-o",
|
||||
"/dev/null",
|
||||
"-X",
|
||||
"POST",
|
||||
f"http://127.0.0.1:{port}/mcp",
|
||||
"-H",
|
||||
"Authorization: Bearer test-token",
|
||||
"-H",
|
||||
"Content-Type: application/json",
|
||||
"-H",
|
||||
"Accept: application/json, text/event-stream",
|
||||
"-d",
|
||||
(
|
||||
'{"jsonrpc":"2.0","id":1,"method":"initialize",'
|
||||
'"params":{"protocolVersion":"2025-03-26",'
|
||||
'"capabilities":{},"clientInfo":{"name":"t","version":"1"}}}'
|
||||
),
|
||||
],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
if probe.returncode == 0 and "HTTP/" in probe.stdout:
|
||||
break
|
||||
time.sleep(0.2)
|
||||
else:
|
||||
self.fail("HTTP server did not become ready in time")
|
||||
|
||||
headers = probe.stdout.lower()
|
||||
self.assertIn("200 ok", headers)
|
||||
self.assertNotIn("mcp-session-id:", headers)
|
||||
finally:
|
||||
proc.terminate()
|
||||
try:
|
||||
proc.wait(timeout=5)
|
||||
except subprocess.TimeoutExpired:
|
||||
proc.kill()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user