Fix page re-navigate

It isn't safe/correct to call `navigate` on the same page multiple times. A page
is meant to have 1 navigate call. The caller should either remove the page
and create a new one, or call Session.replacePage.

This commit removes the *Page from the MCP Server and instead interacts with
the session to create or remove+create the page as needed, and lets the Session
own the *Page.

It also adds a bit of defensiveness around parameter parsing, e.g. calling
{"method": "tools/call"} (without an id) now errors instead of crashing.
This commit is contained in:
Karl Seguin
2026-03-07 10:19:37 +08:00
parent 21313adf9c
commit ae4ad713ec
4 changed files with 42 additions and 27 deletions

View File

@@ -26,6 +26,7 @@ pub const ErrorCode = enum(i64) {
MethodNotFound = -32601,
InvalidParams = -32602,
InternalError = -32603,
PageNotLoaded = -32604,
};
pub const Notification = struct {