NeoGraph 0.16.0
A C++20 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
neograph::a2a::A2AServer Class Reference

HTTP server exposing a NeoGraph as an A2A agent. More...

#include <server.h>

Public Member Functions

 A2AServer (neograph::graph::GraphExecution execution, AgentCard card, std::shared_ptr< GraphAgentAdapter > adapter={})
 Preferred constructor: retain only execution-facing capabilities.
 
 A2AServer (std::shared_ptr< neograph::graph::GraphEngine > engine, AgentCard card, std::shared_ptr< GraphAgentAdapter > adapter={})
 
bool is_running () const
 True once start_async() has the server listening.
 
int port () const
 Bound port — useful when caller passed 0 to bind a free port.
 
void set_http_config (A2AHttpConfig config)
 Set the Host and Origin checks and the request size limit (see A2AHttpConfig).
 
void set_trust_forwarded_headers (bool enabled)
 When the card has no configured url, the served card advertises the address the client used, with the http scheme.
 
bool start (const std::string &host, int port)
 Bind + listen.
 
bool start_async (const std::string &host, int port)
 Bind + spawn a worker thread; returns when the server is ready to accept connections.
 
void stop ()
 Signal the server to stop accepting connections and join.
 

Detailed Description

HTTP server exposing a NeoGraph as an A2A agent.

card.name = "my-agent";
card.url = "http://0.0.0.0:8080/";
a2a::A2AServer server(my_engine, card);
server.start("0.0.0.0", 8080); // blocks until stop()
HTTP server exposing a NeoGraph as an A2A agent.
Definition server.h:194
Subset of AgentCard required to interact (spec §5.5).
Definition types.h:222
std::string url
Public endpoint of the JSON-RPC binding.
Definition types.h:231

When NEOGRAPH_BUILD_PROGRAM is enabled, the ProgramAgentAdapter overload projects an admitted ProgramVersion through ProgramRuntime while retaining the same JSON-RPC methods and legacy GraphEngine constructor.

Definition at line 194 of file server.h.

Constructor & Destructor Documentation

◆ A2AServer()

neograph::a2a::A2AServer::A2AServer ( std::shared_ptr< neograph::graph::GraphEngine >  engine,
AgentCard  card,
std::shared_ptr< GraphAgentAdapter >  adapter = {} 
)
Parameters
engineThe graph engine that handles incoming messages.
cardDiscovery payload returned at /.well-known/agent-card.json.
adapterOptional input/output mapping override.

Member Function Documentation

◆ set_http_config()

void neograph::a2a::A2AServer::set_http_config ( A2AHttpConfig  config)

Set the Host and Origin checks and the request size limit (see A2AHttpConfig).

Without a call, a loopback bind answers only the loopback Host names and its own loopback origin, a remote bind checks no Host and admits a request that carries an Origin only when it is listed, and bodies are limited to the default of A2AHttpConfig::max_payload_bytes.

Exceptions
std::invalid_argumentfor an allowed_hosts entry that is not a host name without a port, an IPv6 address in brackets or *, or for a zero max_payload_bytes.
std::logic_errorwhile the server is listening: call it before start() or start_async().

◆ set_trust_forwarded_headers()

void neograph::a2a::A2AServer::set_trust_forwarded_headers ( bool  enabled)

When the card has no configured url, the served card advertises the address the client used, with the http scheme.

Behind a TLS-terminating reverse proxy, either configure AgentCard::url (the public URL, always preferred) or enable this to take the scheme and host from RFC 7239 Forwarded, else X-Forwarded-Proto / X-Forwarded-Host. Off by default: those headers are set by the client unless a proxy you control overwrites them. A server bound to a loopback address also answers the proxy's public Host only when A2AHttpConfig::allowed_hosts lists it.

◆ start()

bool neograph::a2a::A2AServer::start ( const std::string &  host,
int  port 
)

Bind + listen.

Blocks the calling thread.

Returns
false if bind/listen fails. Empty discovery URLs use the bound host/port and follow later rebinds; an explicitly configured public URL is preserved.

◆ start_async()

bool neograph::a2a::A2AServer::start_async ( const std::string &  host,
int  port 
)

Bind + spawn a worker thread; returns when the server is ready to accept connections.

Use stop() to shut down. Applies the same discovery URL rule as start(), including ephemeral ports.

◆ stop()

void neograph::a2a::A2AServer::stop ( )

Signal the server to stop accepting connections and join.

Requests already being handled are answered first, a stream with at least its opening Task; a request that arrives meanwhile gets JSON-RPC error -32603 (reason UNAVAILABLE). Open streams and blocking sends end when their runs publish a final state, and a stop never cancels a run.


The documentation for this class was generated from the following file: