Skip to main content
Glama

get_pico_info

Retrieve hardware device information via serial communication using this command, enabling control of physical devices through natural language interactions with the MCP2Serial server.

Instructions

Execute get_pico_info command

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function that implements the logic for 'get_pico_info' by gathering and formatting Pico board system information (board name, MicroPython version, CPU frequency, memory, and disk usage).
    def get_pico_info(): d = uos.uname() board_name = d[4] micropython_version = d[2] system_freq = machine.freq() // 1000000 # 系统频率 (MHz) memory_info = gc.mem_free() + gc.mem_alloc() # 内存信息 disk_info = uos.statvfs('/') total_disk_size = disk_info[0] * disk_info[2] free_disk_size = disk_info[0] * disk_info[3] # 拼接信息字符串 info = ( f"Board: {board_name}, " f"MicroPython: {micropython_version}, " f"Freq: {system_freq} MHz, " f"Memory: {memory_info} bytes, " f"Disk: Total {total_disk_size} bytes, Free {free_disk_size} bytes" ) return info
  • Serial command dispatcher that invokes get_pico_info() upon receiving 'PICO_INFO' command over serial and outputs the response in 'OK {info}' format.
    elif user_input.strip() == "PICO_INFO": info = get_pico_info() print(f"OK {info}")
  • Registers the 'get_pico_info' MCP tool dynamically from config.commands by generating Tool objects with name, description, and inputSchema derived from command template placeholders.
    @server.list_tools() async def handle_list_tools() -> list[types.Tool]: """List available tools for the MCP service.""" logger.info("Listing available tools") tools = [] for cmd_id, command in config.commands.items(): # 从命令字符串中提取参数名 import re param_names = re.findall(r'\{(\w+)\}', command.command) properties = {name: {"type": "string"} for name in param_names} tools.append(types.Tool( name=cmd_id, description=f"Execute {cmd_id} command", inputSchema={ "type": "object", "properties": properties, "required": param_names }, prompts=command.prompts )) return tools
  • MCP server tool call handler that executes 'get_pico_info' by looking up the serial command in config.commands['get_pico_info'] and sending it to the device via serial_connection.send_command, returning the response.
    @server.call_tool() async def handle_call_tool(name: str, arguments: dict[str, Any] | None) -> list[types.TextContent]: """Handle tool execution requests according to MCP protocol.""" logger.info(f"Tool call received - Name: {name}, Arguments: {arguments}") try: if name not in config.commands: error_msg = f"[MCP2Serial v{VERSION}] Error: Unknown tool '{name}'\n" error_msg += "Please check:\n" error_msg += "1. Tool name is correct\n" error_msg += "2. Tool is configured in config.yaml" return [types.TextContent( type="text", text=error_msg )] command = config.commands[name] if arguments is None: arguments = {} # 发送命令并返回 MCP 格式的响应 return serial_connection.send_command(command, arguments) except Exception as e: logger.error(f"Error handling tool call: {str(e)}") error_msg = f"[MCP2Serial v{VERSION}] Error: {str(e)}\n" error_msg += "Please check:\n" error_msg += "1. Configuration is correct\n" error_msg += "2. Device is functioning properly" return [types.TextContent( type="text", text=error_msg )]
  • Dynamically generates the inputSchema for 'get_pico_info' tool by extracting parameter names from curly braces {} in the config command template and defining them as string properties.
    # 从命令字符串中提取参数名 import re param_names = re.findall(r'\{(\w+)\}', command.command) properties = {name: {"type": "string"} for name in param_names} tools.append(types.Tool( name=cmd_id, description=f"Execute {cmd_id} command", inputSchema={ "type": "object", "properties": properties, "required": param_names }, prompts=command.prompts ))

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mcp2everything/mcp2serial'

If you have feedback or need assistance with the MCP directory API, please join our Discord server