cxxmcp 1.1.6
C++ MCP SDK
Loading...
Searching...
No Matches
process_stdio_transport.hpp
Go to the documentation of this file.
1// Copyright (c) 2025 [caomengxuan666]
2
3#pragma once
4
7
8#include <chrono>
9#include <memory>
10#include <optional>
11#include <string>
12#include <unordered_map>
13#include <vector>
14
16
17namespace mcp::transport {
18
24 std::string command;
25
27 std::vector<std::string> args;
28
30 std::string cwd;
31
33 std::unordered_map<std::string, std::string> env;
34
37 std::optional<std::chrono::milliseconds> request_timeout =
38 std::chrono::seconds(30);
39};
40
51 public:
55
58 delete;
59
60 std::string_view name() const noexcept override;
61 protocol::Json diagnostics() const override;
62 core::Result<core::Unit> send(TxMessage message) override;
63 core::Result<std::optional<RxMessage>> receive() override;
64 core::Result<core::Unit> close() override;
65
66 private:
67 class Impl;
68
69 std::unique_ptr<Impl> impl_;
70};
71
72} // namespace mcp::transport
Native transport-contract client for a child MCP server over stdio.
Definition process_stdio_transport.hpp:50
core::Result< core::Unit > close() override
Closes the transport and unblocks receive() where possible.
core::Result< std::optional< RxMessage > > receive() override
Receives the next JSON-RPC message from the peer.
std::string_view name() const noexcept override
Human-readable transport name for diagnostics.
protocol::Json diagnostics() const override
Structured implementation diagnostics.
core::Result< core::Unit > send(TxMessage message) override
Sends one JSON-RPC message to the peer.
Minimal message-level transport contract shared by MCP roles.
Definition transport.hpp:38
Configuration for a child-process stdio client transport.
Definition process_stdio_transport.hpp:22
std::optional< std::chrono::milliseconds > request_timeout
Optional maximum time to wait for a JSON-RPC response from the child.
Definition process_stdio_transport.hpp:37
std::vector< std::string > args
Command-line arguments passed to the executable.
Definition process_stdio_transport.hpp:27
std::string cwd
Optional working directory for the child process.
Definition process_stdio_transport.hpp:30
std::unordered_map< std::string, std::string > env
Extra environment variables for the child process.
Definition process_stdio_transport.hpp:33
std::string command
Executable to launch.
Definition process_stdio_transport.hpp:24
Role-generic MCP transport contract for SDK peer/service layers.