Overwriting the Dispatcher

User may want to overwrite the MCP message dispatcher method i.e update to inject custom application behavior, expecting to be executed every iteration(or frame):

client.cpp
while(1)
{
    myMcpClient.update();
    mbase::sleep(5); // in order to prevent resource exhaustion
}
server.cpp
while(mcpServer.is_processor_running())
{
    mcpServer.update();
    mbase::sleep(5); // in order to prevent resource exhaustion
}

MCP Server

The update method is defined under the McpServerBase class:

mcp_server_base.h
class MBASE_API McpServerBase : public mbase::logical_processor {
public:
    ...

    // updates the server state
    GENERIC update() override
    {
        // Should be called every frame.
    }
    ...
private:
    ...
};

In which the McpServerStdio, McpServerHttpStreamableStateful and McpServerHttpStreamableStateless inherit from:

mcp_server_stdio.h
class MBASE_API McpServerStdio : public mbase::McpServerBase {
    ...
};
mcp_server_http_streamable.h
class MBASE_API McpServerHttpStreamableStateful : public mbase::McpServerHttpBase {
    ...
};

class MBASE_API McpServerHttpStreamableStateless : public mbase::McpServerHttpBase {
    ...
};

The assumption of STDIO transport will result with the following example implementation:

server.cpp
class ExampleDerivedServer : public mbase::McpServerStdio {
public:
    ExampleDerivedServer() : mbase::McpServerStdio("MCP Sample Server","1.0.0"){}
    void update() override
    {
        this->default_update_method();
        // your logic is here
    }
};

MCP Client

The update method is defined under the McpClientBase class:

mcp_client_base.h
class MBASE_API McpClientBase {
public:
    ...
    // updates the server state
    virtual GENERIC update()
    {
        // Should be called every frame
    }
    ...
private:
    ...
};