- Refactor server to use a generic transport interface - Add HttpTransport for JSON-RPC and REST over HTTP - Move existing STDIO logic into a StdioTransport - Enable dual-mode (STDIO/HTTP) via command-line flags - Add new examples and docs for HTTP server usage
28 lines
653 B
V
28 lines
653 B
V
module mcp
|
|
|
|
import log
|
|
import freeflowuniverse.herolib.schemas.jsonrpc
|
|
import freeflowuniverse.herolib.mcp.transport
|
|
|
|
// Server is the main MCP server struct
|
|
@[heap]
|
|
pub struct Server {
|
|
ServerConfiguration
|
|
pub mut:
|
|
client_config ClientConfiguration
|
|
handler jsonrpc.Handler
|
|
backend Backend
|
|
transport transport.Transport
|
|
}
|
|
|
|
// start starts the MCP server using the configured transport
|
|
pub fn (mut s Server) start() ! {
|
|
log.info('Starting MCP server')
|
|
s.transport.start(&s.handler)!
|
|
}
|
|
|
|
// send sends a response to the client using the configured transport
|
|
pub fn (mut s Server) send(response string) {
|
|
s.transport.send(response)
|
|
}
|