Append fastMCP model
This commit is contained in:
@@ -291,3 +291,9 @@ docker run -it --rm --network host evilfisru/lwa:jazzy-lwa7-noble
|
||||
# dev - src остаётся для отладки
|
||||
`docker build --build-arg BUILD_TYPE=dev -t my-image .`
|
||||
```
|
||||
|
||||
```
|
||||
# URL для доступа к MCP LLM
|
||||
http://localhost:8007/mcp/mcp
|
||||
|
||||
```
|
||||
@@ -12,3 +12,9 @@ python3-multipart:
|
||||
ubuntu:
|
||||
pip:
|
||||
packages: [python-multipart]
|
||||
|
||||
python3-fastmcp:
|
||||
ubuntu:
|
||||
pip:
|
||||
packages: [fastmcp]
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ endpoints:
|
||||
msg_type: std_srvs/srv/Trigger
|
||||
summary: "Немедленно остановить движение"
|
||||
description: "Вызывает сервис экстренной остановки — движение прерывается немедленно."
|
||||
tags: [robot]
|
||||
tags: [motion]
|
||||
response_fields: [success, message]
|
||||
timeout: 5.0
|
||||
enabled: true
|
||||
|
||||
@@ -4,6 +4,7 @@ from contextlib import asynccontextmanager
|
||||
import rclpy
|
||||
import uvicorn
|
||||
from fastapi import FastAPI
|
||||
from fastmcp import FastMCP
|
||||
from sensor_msgs.msg import JointState
|
||||
|
||||
from .dynamic_router import build_dynamic_router
|
||||
@@ -22,15 +23,25 @@ def main():
|
||||
endpoints_path = node.get_parameter('endpoints_path').value or None
|
||||
joint_limits_path = node.get_parameter('joint_limits_path').value or None
|
||||
|
||||
_schema_app = FastAPI()
|
||||
_schema_app.include_router(build_dynamic_router(endpoints_path, joint_limits_path))
|
||||
_schema_app.include_router(runner.router)
|
||||
_schema_app.include_router(trajectory.router)
|
||||
|
||||
mcp = FastMCP.from_fastapi(app=_schema_app)
|
||||
mcp_http = mcp.http_app(path='/mcp')
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(_: FastAPI):
|
||||
get_bridge().subscribe("/joint_states", JointState)
|
||||
yield
|
||||
async with mcp_http.router.lifespan_context(_):
|
||||
get_bridge().subscribe("/joint_states", JointState)
|
||||
yield
|
||||
|
||||
app = FastAPI(lifespan=lifespan)
|
||||
app.include_router(build_dynamic_router(endpoints_path, joint_limits_path))
|
||||
app.include_router(runner.router)
|
||||
app.include_router(trajectory.router)
|
||||
app.mount("/mcp", mcp_http)
|
||||
|
||||
uvicorn.run(app, host=host, port=port)
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ setup(
|
||||
'fastapi',
|
||||
'uvicorn[standard]',
|
||||
'python-multipart',
|
||||
'fastmcp',
|
||||
],
|
||||
zip_safe=True,
|
||||
maintainer='daniel',
|
||||
|
||||
Reference in New Issue
Block a user