feat(cli): mcp serve curated stdio MCP server

`weknora mcp serve` — long-lived stdio MCP (Model Context Protocol)
transport that exposes a fixed, curated tool surface to MCP-aware
agents (Claude Desktop, Claude Code, custom MCP clients).

Curated tool set (readonly by default):
- whoami — active context + tenant
- search (hybrid retrieval against a KB)
- kb list / view
- doc list / view
- agent list / view / invoke
- session list / view

The list is intentionally narrow to the read + agent-invoke surface;
destructive verbs (`delete` / `empty` / `upload`) are gated behind
`--write`. Schema is built from each leaf cobra command's flags so
adding a new tool is a single registry entry plus a Service interface.

Includes the simplify post-review polish + a second simplify pass to
fold the resulting feedback (typed schemas, agent_help wording, unify
chat / agent invoke option names).
This commit is contained in:
nullkey
2026-05-14 23:28:14 +08:00
committed by lyingbug
parent 493fc41e98
commit 9bb83b47fd
14 changed files with 1213 additions and 154 deletions
+9 -1
View File
@@ -119,7 +119,15 @@ func runList(ctx context.Context, opts *ListOptions, jopts *cmdutil.JSONOptions,
}
if jopts.Enabled() {
meta := &format.Meta{HasMore: opts.Page*opts.PageSize < total}
// When --since is active, has_more is meaningless: the server's
// total counts all sessions but the page is now client-side
// filtered. An agent walking pages would see has_more=true even
// when no later page can contain matching items. Drop the flag
// rather than mislead. The agent_help string documents this.
meta := &format.Meta{}
if since == 0 {
meta.HasMore = opts.Page*opts.PageSize < total
}
return format.WriteEnvelopeFiltered(
iostreams.IO.Out,
format.Success(listResult{Items: items}, meta),