mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-02 12:05:54 +00:00
CI on feat/sandbox failed across Unit Tests, Lint and Build Dev Image.
Root causes and fixes:
- pyproject.toml had a [tool.uv.sources] editable override pinning
langbot-plugin to ../langbot-plugin-sdk. That path only exists in a
paired local checkout, so `uv sync` failed on every CI runner
("Distribution not found"). Remove the override and regenerate uv.lock
so langbot-plugin==0.4.0b1 resolves from PyPI, matching master.
- tests/integration/api/test_pipelines.py: the pipeline extensions
endpoint now calls ap.skill_service.list_skills(); add the missing
skill_service mock to the fake_pipeline_app fixture (the test came
from master, the endpoint change from feat/sandbox).
- Apply ruff format to three src files and prettier to three web files
that had committed formatting drift, failing `ruff format --check`
and `pnpm lint`.
69 lines
2.8 KiB
Python
69 lines
2.8 KiB
Python
from __future__ import annotations
|
|
|
|
import quart
|
|
import traceback
|
|
|
|
|
|
from ... import group
|
|
|
|
|
|
@group.group_class('mcp', '/api/v1/mcp')
|
|
class MCPRouterGroup(group.RouterGroup):
|
|
async def initialize(self) -> None:
|
|
@self.route('/servers', methods=['GET', 'POST'], auth_type=group.AuthType.USER_TOKEN)
|
|
async def _() -> str:
|
|
"""获取MCP服务器列表"""
|
|
if quart.request.method == 'GET':
|
|
servers = await self.ap.mcp_service.get_mcp_servers(contain_runtime_info=True)
|
|
|
|
return self.success(data={'servers': servers})
|
|
|
|
elif quart.request.method == 'POST':
|
|
data = await quart.request.json
|
|
|
|
try:
|
|
uuid = await self.ap.mcp_service.create_mcp_server(data)
|
|
return self.success(data={'uuid': uuid})
|
|
except Exception as e:
|
|
traceback.print_exc()
|
|
return self.http_status(500, -1, f'Failed to create MCP server: {str(e)}')
|
|
|
|
@self.route('/servers/<server_name>', methods=['GET', 'PUT', 'DELETE'], auth_type=group.AuthType.USER_TOKEN)
|
|
async def _(server_name: str) -> str:
|
|
"""获取、更新或删除MCP服务器配置"""
|
|
from urllib.parse import unquote
|
|
|
|
server_name = unquote(server_name)
|
|
|
|
server_data = await self.ap.mcp_service.get_mcp_server_by_name(server_name)
|
|
if server_data is None:
|
|
return self.http_status(404, -1, 'Server not found')
|
|
|
|
if quart.request.method == 'GET':
|
|
return self.success(data={'server': server_data})
|
|
|
|
elif quart.request.method == 'PUT':
|
|
data = await quart.request.json
|
|
try:
|
|
await self.ap.mcp_service.update_mcp_server(server_data['uuid'], data)
|
|
return self.success()
|
|
except Exception as e:
|
|
return self.http_status(500, -1, f'Failed to update MCP server: {str(e)}')
|
|
|
|
elif quart.request.method == 'DELETE':
|
|
try:
|
|
await self.ap.mcp_service.delete_mcp_server(server_data['uuid'])
|
|
return self.success()
|
|
except Exception as e:
|
|
return self.http_status(500, -1, f'Failed to delete MCP server: {str(e)}')
|
|
|
|
@self.route('/servers/<server_name>/test', methods=['POST'], auth_type=group.AuthType.USER_TOKEN)
|
|
async def _(server_name: str) -> str:
|
|
"""测试MCP服务器连接"""
|
|
from urllib.parse import unquote
|
|
|
|
server_name = unquote(server_name)
|
|
server_data = await quart.request.json
|
|
task_id = await self.ap.mcp_service.test_mcp_server(server_name=server_name, server_data=server_data)
|
|
return self.success(data={'task_id': task_id})
|