Skip to content

✨ knowledge: owner-switched, read-only public MCP endpoint for external agents - #10621

Merged
clubanderson merged 19 commits into
v5from
feat/public-knowledge-mcp-10615
Oct 5, 2026
Merged

clubanderson merged 19 commits into
v5from
feat/public-knowledge-mcp-10615

Conversation

@clubanderson

Copy link
Copy Markdown
Member

Closes #10615. cc @castrojo — this is the "public knowledge" switch for Bluefin's Troubleshooting / mcp.projectbluefin.io.

Stacked on #10617 (v5 currently panics at pkg/dashboard/pkg/hub init, so nothing in those packages can be tested until it lands). The first three commits here are that fix; this PR's own diff starts at ✨ knowledge: owner-switched read-only public MCP endpoint.

What

An owner-controlled, strictly read-only MCP endpoint that lets any external agent (Goose, Claude, Copilot CLI, curl) read a hive's operational knowledge with no credentials — but only after the hive owner opts in.

Endpoint POST /mcp/knowledge — MCP Streamable HTTP, JSON-RPC 2.0, JSON responses (no SSE)
Switch HIVE_PUBLIC_KNOWLEDGE=1|true|yes|on — default off → 404, even for the owner. Read per-request; close it without a pod roll.
Narrowing HIVE_PUBLIC_KNOWLEDGE_TAGS=linux,troubleshooting — optional tag allow-list
Tools knowledge_search {query,type?,limit?} · knowledge_get {slug} · knowledge_export {} (Markdown + ETag)

Read-only guarantees

  • The handler serves initialize, ping, notifications/*, tools/list, tools/call and nothing else (-32601 otherwise).
  • No code path from this file reaches CreateFact/UpdateFact/DeleteFact, import, promotion, or vault mutation. Tests assert no tool name contains create/update/delete/write/import/promote and that every tool is annotated readOnlyHint: true, destructiveHint: false.
  • POST-only (mux 405s other verbs), 64 KiB body cap, ≤50 results per search.

What leaves the hive

Only operational types: pattern, gotcha, regression, test_scaffold, integration, coverage_rule, general. Ideation/governance types (idea, vision, constitution, requirement, constraint, stakeholder, decision) are filtered at a single choke point (publicKnowledgeFilter); fetching one by slug answers not found, not forbidden. Each fact is projected to slug/title/type/body/tags/related (+confidence only when scored) — sources, usage_count, confidence_reason, last_used, phase are stripped.

Plumbing

Try it

HIVE_PUBLIC_KNOWLEDGE=1 ...
curl -s $HIVE/mcp/knowledge -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"knowledge_search","arguments":{"query":"bluetooth"}}}'

Goose: extensions: { hive: { type: streamable_http, uri: https://<hive>/mcp/knowledge } }

Verification

  • go test -run 'PublicKnowledge|GithubLogin' ./pkg/dashboard/ ✅ (9 tests: default-off, off-even-when-authenticated, spellings, handshake/tools-list, private-type hiding in search/get/export, tag allow-list, write/bad-input rejection, no-KB, path constant)
  • go test -run PublicKnowledgeMCP ./pkg/hub/ ✅
  • go test -cover ./pkg/hub/ ✅ 89.2%; ./pkg/dashboard/ 85.0% — two failures there (TestOpenAPISpecCoversEveryRegisteredRoute: undocumented GET /api/feedback/status; TestAgentsCollapsedSummaryRendersPerAgentTiles) are pre-existing on v5 and unrelated.
  • go vet, check-api-reference-citations.sh ✅

clubanderson and others added 10 commits October 5, 2026 11:52
regexp.MustCompile at package init used (?=...), which Go's RE2 engine
does not support, so pkg/dashboard panicked on load (spoke startup and
every dashboard test). Express the no-double-hyphen rule without
lookahead and enforce the 39-char cap explicitly; add a table test.

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Generated by changelog-fragment-guard from the PR title (#5675).
Edit the wording freely, or replace this file with the no-changelog
label if the change is not user-visible.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: clubanderson <407614+clubanderson@users.noreply.github.com>
pkg/hub/feedback.go carried the identical (?=...) pattern, so the hub
binary and every hub test panicked at init too. Same rewrite + length
cap + table test.

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Add POST /mcp/knowledge, a Model Context Protocol endpoint any external
agent can use anonymously to read this hive's operational knowledge —
but only after the owner sets HIVE_PUBLIC_KNOWLEDGE. Default off (404).

Strictly read-only: the surface serves initialize/ping/tools/list and
three tools (knowledge_search, knowledge_get, knowledge_export). No
code path reaches CreateFact/UpdateFact/DeleteFact or vault mutation.
Only operational fact types are projected; ideation/governance types,
sources, usage counters and confidence reasoning never leave the hive.
Optional HIVE_PUBLIC_KNOWLEDGE_TAGS narrows the projection further.

isPublicPath (spoke) and publicExactPaths (hub nginx auth_request) wave
the path through only so the handler can run its own fail-closed check.

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
env-vars, api-reference (+citation refresh), documentation map, a new
public-knowledge-mcp.md with Goose/Claude/Copilot client snippets, and
the changelog fragment for #10615.

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
…tations verify

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
…ctly

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign danathar for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Oct 5, 2026
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

Conflicts are checked with every PR merged onto the current tip of v5, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#10618 ✨ Improve collapsed Advisory and ACMM headers same files src/docs/api-reference.md
#10517 📖 docs: add unreviewed ACMM Level 6 operating guide same files src/docs/documentation-map.md
#10608 📖 docs: refresh api-reference citations after #10607 same files src/docs/api-reference.md
#10602 ✨ feat: label-driven repos skip un-park notice and keep needs-human same files src/docs/api-reference.md
#10638 🐛 dashboard: Overview open-issue/PR totals explain their gap to the forge counts same files src/docs/api-reference.md
src/pkg/dashboard/server.go
#10594 🧪 test: restore pkg/github coverage floor after reporter-trust wait same files src/docs/api-reference.md
#10632 ✨ dashboard: Agents sidebar link + up-next agent tiles in top navbar same files src/docs/api-reference.md
#10604 🐛 hub dashboard: NPS section header matches sibling section styling same files src/docs/api-reference.md
#10589 🐛 fix: route reporter-trust waits through poller relay same files src/docs/api-reference.md

@github-actions github-actions Bot added the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 5, 2026
Generated by changelog-fragment-guard from the PR title (#5675).
Edit the wording freely, or replace this file with the no-changelog
label if the change is not user-visible.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: clubanderson <407614+clubanderson@users.noreply.github.com>
Signed-off-by: Andrew Anderson <andy@clubanderson.com>
…ing, MCP 2025-06-18

- knowledge_get/export/search re-read facts by slug so bodies are not the
  200-rune store snippets
- enforce the type filter after search (vault/git stores ignore it)
- over-fetch 10x before the public filter so private facts cannot starve
  the result window
- filter Related down to public slugs
- advertise MCP 2025-06-18 and reject JSON-RPC batches with -32600

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
… to #10621)

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Signed-off-by: Andrew Anderson <andy@clubanderson.com>
…edge-mcp-10615

Signed-off-by: Andrew Anderson <andy@clubanderson.com>

# Conflicts:
#	src/docs/api-reference.md
#	src/pkg/dashboard/mcp_knowledge.go
#	src/pkg/dashboard/mcp_knowledge_test.go
Signed-off-by: Andrew Anderson <andy@clubanderson.com>
clubanderson added a commit that referenced this pull request Oct 5, 2026
… regexp (#10617)

* 🐛 fix: dashboard init panic from lookahead in feedback login regexp

regexp.MustCompile at package init used (?=...), which Go's RE2 engine
does not support, so pkg/dashboard panicked on load (spoke startup and
every dashboard test). Express the no-double-hyphen rule without
lookahead and enforce the 39-char cap explicitly; add a table test.

Signed-off-by: Andrew Anderson <andy@clubanderson.com>

* changelog: fragment for #10617

Generated by changelog-fragment-guard from the PR title (#5675).
Edit the wording freely, or replace this file with the no-changelog
label if the change is not user-visible.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: clubanderson <407614+clubanderson@users.noreply.github.com>

* 🐛 fix: same lookahead regexp panic in pkg/hub feedback login validator

pkg/hub/feedback.go carried the identical (?=...) pattern, so the hub
binary and every hub test panicked at init too. Same rewrite + length
cap + table test.

Signed-off-by: Andrew Anderson <andy@clubanderson.com>

* changelog: drop duplicate fragment (bot added fixed-10617.md)

Signed-off-by: Andrew Anderson <andy@clubanderson.com>

* fix: drop public-knowledge MCP files that leaked into this PR (belong to #10621)

Signed-off-by: Andrew Anderson <andy@clubanderson.com>

* docs: refresh api-reference citations (drifted on v5)

Signed-off-by: Andrew Anderson <andy@clubanderson.com>

---------

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Signed-off-by: clubanderson <407614+clubanderson@users.noreply.github.com>
Co-authored-by: clubanderson <407614+clubanderson@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…cp-10615

Signed-off-by: Andrew Anderson <andy@clubanderson.com>

# Conflicts:
#	src/docs/api-reference.md
@github-actions github-actions Bot removed the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 5, 2026
@clubanderson
clubanderson merged commit f027857 into v5 Oct 5, 2026
53 of 59 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the feat/public-knowledge-mcp-10615 branch October 5, 2026 16:57
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨ Public knowledge: owner-controlled, read-only MCP endpoint for external agents

1 participant