Files
RetroArch/network/mcp_server.h
libretroadmin 714db64c8b MCP server: stdio transport with log notifications
--mcp-stdio serves MCP on stdin and stdout as newline-delimited
JSON-RPC, for a client that starts RetroArch itself; no token is asked.
It takes the stdout descriptor for the protocol at option parsing and
points stdout at stderr, so RetroArch's log and a core's prints never
reach the client's stream. Reads and writes never wait: a line is
handled once whole, answers are queued and written as the pipe takes
them, and both outlive the server across a content load. It offers
logging: after logging/setLevel, new lines from the GET_LOG ring at
that level and above go out as notifications/message from the poll, so
the threads that log do no more than before. Closing stdin quits.
2026-10-12 23:34:51 +02:00

51 lines
1.7 KiB
C

/* RetroArch - A frontend for libretro.
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __RARCH_MCP_SERVER_H
#define __RARCH_MCP_SERVER_H
#include <stdint.h>
#include <retro_common_api.h>
#include "../command.h"
RETRO_BEGIN_DECLS
/**
* command_mcp_new:
* @port : TCP port to listen on.
* @bind_address : Address to listen on; empty means 127.0.0.1.
* @token : Bearer token every request must carry; the
* server does not start without one.
*
* The MCP server, as a command interface: tools are the commands in
* command.h, served over the Model Context Protocol's Streamable HTTP
* transport at http://<address>:<port>/mcp.
*
* Returns: the interface, or NULL when it could not listen.
**/
command_t *command_mcp_new(uint16_t port, const char *bind_address,
const char *token);
/* The stdio transport (--mcp-stdio): claim takes stdin and stdout for
* it, early, and points what else writes to stdout at stderr; new
* makes the server on them, NULL until claimed. */
bool command_mcp_stdio_claim(void);
bool command_mcp_stdio_claimed(void);
command_t *command_mcp_stdio_new(void);
RETRO_END_DECLS
#endif