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 остаётся для отладки
|
# dev - src остаётся для отладки
|
||||||
`docker build --build-arg BUILD_TYPE=dev -t my-image .`
|
`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:
|
ubuntu:
|
||||||
pip:
|
pip:
|
||||||
packages: [python-multipart]
|
packages: [python-multipart]
|
||||||
|
|
||||||
|
python3-fastmcp:
|
||||||
|
ubuntu:
|
||||||
|
pip:
|
||||||
|
packages: [fastmcp]
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ endpoints:
|
|||||||
msg_type: std_srvs/srv/Trigger
|
msg_type: std_srvs/srv/Trigger
|
||||||
summary: "Немедленно остановить движение"
|
summary: "Немедленно остановить движение"
|
||||||
description: "Вызывает сервис экстренной остановки — движение прерывается немедленно."
|
description: "Вызывает сервис экстренной остановки — движение прерывается немедленно."
|
||||||
tags: [robot]
|
tags: [motion]
|
||||||
response_fields: [success, message]
|
response_fields: [success, message]
|
||||||
timeout: 5.0
|
timeout: 5.0
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from contextlib import asynccontextmanager
|
|||||||
import rclpy
|
import rclpy
|
||||||
import uvicorn
|
import uvicorn
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
|
from fastmcp import FastMCP
|
||||||
from sensor_msgs.msg import JointState
|
from sensor_msgs.msg import JointState
|
||||||
|
|
||||||
from .dynamic_router import build_dynamic_router
|
from .dynamic_router import build_dynamic_router
|
||||||
@@ -22,15 +23,25 @@ def main():
|
|||||||
endpoints_path = node.get_parameter('endpoints_path').value or None
|
endpoints_path = node.get_parameter('endpoints_path').value or None
|
||||||
joint_limits_path = node.get_parameter('joint_limits_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
|
@asynccontextmanager
|
||||||
async def lifespan(_: FastAPI):
|
async def lifespan(_: FastAPI):
|
||||||
get_bridge().subscribe("/joint_states", JointState)
|
async with mcp_http.router.lifespan_context(_):
|
||||||
yield
|
get_bridge().subscribe("/joint_states", JointState)
|
||||||
|
yield
|
||||||
|
|
||||||
app = FastAPI(lifespan=lifespan)
|
app = FastAPI(lifespan=lifespan)
|
||||||
app.include_router(build_dynamic_router(endpoints_path, joint_limits_path))
|
app.include_router(build_dynamic_router(endpoints_path, joint_limits_path))
|
||||||
app.include_router(runner.router)
|
app.include_router(runner.router)
|
||||||
app.include_router(trajectory.router)
|
app.include_router(trajectory.router)
|
||||||
|
app.mount("/mcp", mcp_http)
|
||||||
|
|
||||||
uvicorn.run(app, host=host, port=port)
|
uvicorn.run(app, host=host, port=port)
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ setup(
|
|||||||
'fastapi',
|
'fastapi',
|
||||||
'uvicorn[standard]',
|
'uvicorn[standard]',
|
||||||
'python-multipart',
|
'python-multipart',
|
||||||
|
'fastmcp',
|
||||||
],
|
],
|
||||||
zip_safe=True,
|
zip_safe=True,
|
||||||
maintainer='daniel',
|
maintainer='daniel',
|
||||||
|
|||||||
Reference in New Issue
Block a user