mirror of
https://github.com/Tencent/WeKnora.git
synced 2026-09-01 14:53:07 +08:00
9bb83b47fd
`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).
38 lines
843 B
Go
38 lines
843 B
Go
package format
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
|
|
sdk "github.com/Tencent/WeKnora/client"
|
|
)
|
|
|
|
// WriteReferences renders the compact references footer used by chat and
|
|
// agent invoke: a horizontal rule, one numbered line per reference,
|
|
// best-available title + optional score. Skipped entirely when refs is
|
|
// empty — agent-friendly silence beats an empty banner.
|
|
func WriteReferences(w io.Writer, refs []*sdk.SearchResult) {
|
|
if len(refs) == 0 {
|
|
return
|
|
}
|
|
fmt.Fprintln(w)
|
|
fmt.Fprintln(w, "──── References ────")
|
|
for i, r := range refs {
|
|
if r == nil {
|
|
continue
|
|
}
|
|
title := r.KnowledgeTitle
|
|
if title == "" {
|
|
title = r.KnowledgeFilename
|
|
}
|
|
if title == "" {
|
|
title = r.KnowledgeID
|
|
}
|
|
fmt.Fprintf(w, "[%d] %s", i+1, title)
|
|
if r.Score > 0 {
|
|
fmt.Fprintf(w, " score=%.3f", r.Score)
|
|
}
|
|
fmt.Fprintln(w)
|
|
}
|
|
}
|