Skip to content

Conversation

@stex2005
Copy link
Collaborator

@stex2005 stex2005 commented Dec 1, 2025

Rationale

Tools are great for operations, but they're not ideal for read-only data that gets accessed frequently. Every tool call is a full round-trip with no caching, and LLMs need to know tool names ahead of time to use them.

Features added

MCP Resources solve this by:

  • Caching: Clients can cache resource data, eliminating redundant requests
  • Discovery: Resources appear in list_resources(), so LLMs can discover what's available
  • Aggregation: Single resource call can return comprehensive system state instead of multiple tool calls

For example, getting a full ROS system snapshot currently requires calling get_topics(), get_services(), get_nodes(), and get_parameters() separately. With resources, it's one call to ros-mcp://ros-metadata/all that returns everything, and the client caches it.

Implementation

Added two resources:

  1. ros-mcp://ros-metadata/all - Aggregates all ROS system info (topics, services, nodes, parameters, ROS version) in a single JSON response. Handles ROS1/ROS2 differences gracefully.

  2. ros-mcp://robot-specs/get_all_robots - Lists available robot specification files for discovery.

Both resources are registered in resources/__init__.py and automatically loaded on server startup. Also fixed a bug where the metadata resource was calling the non-existent /rosapi/parameters service - now correctly uses /rosapi/get_param_names.

Fully backward compatible - all existing tools remain unchanged. Resources complement tools rather than replace them.

Future Plans

If we agree, I plan to convert simple read-only list operations (like get_topics(), get_services(), get_nodes()) into resources for better caching and discovery, while keeping parameterized queries (like get_topic_type(topic), get_parameter(name)) as tools since they require specific inputs and benefit from structured error handling. This will help ROS discovery and introspection while keeping the number of tools limited. At the same time I am planning to merge some tools (inspect + details/type) for better clarity.

- Add resources/ros_metadata.py: Resource for getting all ROS metadata (topics, services, nodes, parameters)
- Add resources/robot_specs.py: Resource for listing all available robot specifications
- Fix rosapi parameters service: Use /rosapi/get_param_names instead of /rosapi/parameters
- Add resources/__init__.py: Register all resources with MCP server
- Update server.py: Register MCP resources on startup
@stex2005 stex2005 requested a review from rjohn-v December 1, 2025 02:35
@stex2005 stex2005 self-assigned this Dec 1, 2025
@stex2005 stex2005 added enhancement New feature or request question Further information is requested labels Dec 1, 2025
@stex2005 stex2005 changed the base branch from main to develop December 1, 2025 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request question Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants