Skip to content

feat(hub): host learning MCP with agent connections - #389

Draft
nshki wants to merge 17 commits into
nshki/feat/hub/learning-activityfrom
nshki/feat/hub/learning-mcp
Draft

nshki wants to merge 17 commits into
nshki/feat/hub/learning-activityfrom
nshki/feat/hub/learning-mcp

Conversation

@nshki

@nshki nshki commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Why

Learnings only help if the agents building prototypes can read them. Today an agent can get them only by running the replica-learning command against its own copy of the data. This lets a person connect their coding agent straight to Hub, so it reads the learnings their team accepted there, without copying files or handing the agent a password.

What changes

The Learnings page gets a Connect an agent button. It opens a page with a short MCP configuration to copy into the agent. The configuration holds only Hub's address for that repository, not a secret. The first time the agent calls Hub, it is told to sign in. It opens the browser to an approval page that names the agent, the signed-in person, and where access will be sent. Hub cannot confirm an agent's name, so the page warns when that address is not on the person's computer. If the person approves, the agent gets its own tokens. The same page lists the person's connected agents and lets them revoke any of them.

Hub now serves the learning MCP server that the learning package already provides. Hub loads the package's tools and instructions and supplies the data. An agent can read the repository's accepted learnings and report which ones it applied. Every call acts as the person who approved it, and Hub rechecks their sign-in and repository access each time. Signing out everywhere or losing access stops the agent too. Agent commands share the lock used by other learning work, so they run one at a time. Approving and revoking write security audits.

This removes the Agent connections prototype page; the real page replaces it. The package gains a --purpose option on memories and show, so Hub and the command read learnings the same way agents see them.

sequenceDiagram
  participant A as Agent
  participant H as Hub
  participant P as Person (browser)
  A->>H: Call MCP tool
  H-->>A: 401, sign in here
  A->>H: Register and start sign-in
  H->>P: Approval page
  P->>H: Approve
  H-->>A: One-time code via browser
  A->>H: Trade code for tokens
  A->>H: Call MCP tool with token
  H->>H: Recheck session and repository access
  H-->>A: Learnings
Loading

Needs design review:

  • A connection belongs to a person, not a repository. It works for any repository they can read, so the list is per person.
  • The MCP address uses Hub's repository ID, not the GitHub repository ID.
  • Local repositories are not supported, because learnings are keyed to GitHub repositories. Their Learnings page hides agent setup.
  • Agents read only the repository's own learnings. Shared learnings from other repositories are not recalled yet.
  • Hub refuses submit_session and screenshots in report_usage. Screenshot consent comes in the next layer.
  • Every agent is a public OAuth client that relies on PKCE. Token lifetimes match Canvas connections.
  • The OAuth endpoints live at root paths such as /authorize and /token, as the MCP SDK expects.
  • Individual MCP calls are not audited. Only approving and revoking are.
  • After sign-in, Hub returns to the approval page using the same pattern as Canvas sign-in.
  • Agent connections reuse Canvas authorization, so people signed in through Entra cannot connect agents yet.
  • Agent commands use the single global learning lock, so a busy Hub asks agents to retry rather than queueing them.

Storybook screenshots

These are every Agent connections story and every Learnings story that shows the new header button. Learning detail and access-denied stories don't show the header and are unchanged. The Agent connections prototype stories are removed with the prototype.

Hub/Pages/Learnings/Agent connections/ConnectedAgents (light, 1280×800)

Hub/Pages/Learnings/Agent connections/ConnectedAgents

Hub/Pages/Learnings/Agent connections/NoConnectedAgents (light, 1280×800)

Hub/Pages/Learnings/Agent connections/NoConnectedAgents

Hub/Pages/Learnings/Agent connections/RevokeConfirmation (light, 1280×800)

Hub/Pages/Learnings/Agent connections/RevokeConfirmation

Hub/Pages/Learnings/Agent connections/Revoked (light, 1280×800)

Hub/Pages/Learnings/Agent connections/Revoked

Hub/Pages/Learnings/Agent connections/ApprovalRequest (light, 1280×800)

Hub/Pages/Learnings/Agent connections/ApprovalRequest

Hub/Pages/Learnings/Agent connections/RemoteApprovalRequest (light, 1280×800)

Hub/Pages/Learnings/Agent connections/RemoteApprovalRequest

Hub/Pages/Learnings/Agent connections/LocalRepository (light, 1280×800)

Hub/Pages/Learnings/Agent connections/LocalRepository

Hub/Pages/Learnings/Default (light, 1280×800)

Hub/Pages/Learnings/Default

Hub/Pages/Learnings/DecisionRuntimeNotConfigured (light, 1280×800)

Hub/Pages/Learnings/DecisionRuntimeNotConfigured

Hub/Pages/Learnings/DecisionRuntimeUnavailable (light, 1280×800)

Hub/Pages/Learnings/DecisionRuntimeUnavailable

Hub/Pages/Learnings/RepositoryLearningAuthorityOnly (light, 1280×800)

Hub/Pages/Learnings/RepositoryLearningAuthorityOnly

Hub/Pages/Learnings/DecisionTrainingPaused (light, 1280×800)

Hub/Pages/Learnings/DecisionTrainingPaused

Hub/Pages/Learnings/DecisionTrainingBlocked (light, 1280×800)

Hub/Pages/Learnings/DecisionTrainingBlocked

Hub/Pages/Learnings/DecisionTrainingQueued (light, 1280×800)

Hub/Pages/Learnings/DecisionTrainingQueued

Hub/Pages/Learnings/DecisionTrainingPreparing (light, 1280×800)

Hub/Pages/Learnings/DecisionTrainingPreparing

Hub/Pages/Learnings/DecisionTrainingRunning (light, 1280×800)

Hub/Pages/Learnings/DecisionTrainingRunning

Hub/Pages/Learnings/DecisionTrainingFailures (light, 1280×800)

Hub/Pages/Learnings/DecisionTrainingFailures

Hub/Pages/Learnings/DecisionTrainingCancelled (light, 1280×800)

Hub/Pages/Learnings/DecisionTrainingCancelled

Hub/Pages/Learnings/DecisionCandidatePromoted (light, 1280×800)

Hub/Pages/Learnings/DecisionCandidatePromoted

Hub/Pages/Learnings/DecisionCandidatePromotedWithoutRollback (light, 1280×800)

Hub/Pages/Learnings/DecisionCandidatePromotedWithoutRollback

Hub/Pages/Learnings/DecisionCandidateRolledBack (light, 1280×800)

Hub/Pages/Learnings/DecisionCandidateRolledBack

Hub/Pages/Learnings/DecisionCandidateRejected (light, 1280×800)

Hub/Pages/Learnings/DecisionCandidateRejected

Hub/Pages/Learnings/LegacyBuildEvaluation (light, 1280×800)

Hub/Pages/Learnings/LegacyBuildEvaluation

Hub/Pages/Learnings/RemovedLearningText (light, 1280×800)

Hub/Pages/Learnings/RemovedLearningText

Hub/Pages/Learnings/RuntimeDeletionPending (light, 1280×800)

Hub/Pages/Learnings/RuntimeDeletionPending

Hub/Pages/Learnings/ManyLearnings (light, 1280×800)

Hub/Pages/Learnings/ManyLearnings

Hub/Pages/Learnings/EmptyStatus (light, 1280×800)

Hub/Pages/Learnings/EmptyStatus

Hub/Pages/Learnings/NoSearchResults (light, 1280×800)

Hub/Pages/Learnings/NoSearchResults

Hub/Pages/Learnings/FirstVisit (light, 1280×800)

Hub/Pages/Learnings/FirstVisit

Hub/Pages/Learnings/FailedLearningRun (light, 1280×800)

Hub/Pages/Learnings/FailedLearningRun

Hub/Pages/Learnings/IdentityRevalidation (light, 1280×800)

Hub/Pages/Learnings/IdentityRevalidation

Hub/Pages/Learnings/ReadableMember (light, 1280×800)

Hub/Pages/Learnings/ReadableMember

Hub/Pages/Learnings/CopilotRefused (light, 1280×800)

Hub/Pages/Learnings/CopilotRefused

Hub/Pages/Learnings/Running (light, 1280×800)

Hub/Pages/Learnings/Running

Hub/Pages/Learnings/DailyRunWaiting (light, 1280×800)

Hub/Pages/Learnings/DailyRunWaiting

Hub/Pages/Learnings/FailedRun (light, 1280×800)

Hub/Pages/Learnings/FailedRun

Hub/Pages/Learnings/LoadError (light, 1280×800)

Hub/Pages/Learnings/LoadError

Hub/Pages/Learnings/RedactionFollowUp (light, 1280×800)

Hub/Pages/Learnings/RedactionFollowUp

nshki and others added 6 commits November 25, 2026 22:35
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 25291e01-0146-42cb-ac6d-f5e1dd5c35f5
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 25291e01-0146-42cb-ac6d-f5e1dd5c35f5
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 25291e01-0146-42cb-ac6d-f5e1dd5c35f5
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 25291e01-0146-42cb-ac6d-f5e1dd5c35f5
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 25291e01-0146-42cb-ac6d-f5e1dd5c35f5
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 25291e01-0146-42cb-ac6d-f5e1dd5c35f5
@nshki
nshki added this pull request to stack #367 November 26, 2026 06:59
@nshki
nshki requested an adaptive review from Copilot November 26, 2026 06:59
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 25291e01-0146-42cb-ac6d-f5e1dd5c35f5

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved critical security flaws allow approvals under the wrong account, expose private request data in logs, and permit guidance delivery after revocation or redaction.

20 open issues
1 file not reviewed
  • hub/package-lock.json: Generated file
What changed in this PR

Lets coding agents read accepted learnings directly from Hub through the Model Context Protocol (MCP), using browser-approved connections instead of copying learning stores.

Changes:

  • Adds OAuth approval, token refresh, revocation, and repository-authorized MCP access.
  • Replaces the agent-connections prototype with connected-agent management and approval pages.
  • Adds purpose-specific CLI reads, integration tests, stories, and documentation.
File Description
packages/​learning/​test/​cli.test.mjs Tests instruction-purpose withholding.
packages/​learning/​src/​mcp.mjs Exports host-compatible learning errors.
packages/​learning/​src/​cli.mjs Adds purpose selection to learning reads.
packages/​learning/​README.md Documents purpose reads and host errors.
packages/​learning/​mcp.d.mts Declares the learning-error export.
hub/​server/​start-server-processes/​index.ts Accepts agent-connection dependencies.
hub/​server/​run-api/​index.ts Passes connection dependencies into the app.
hub/​server/​routes/​types.ts Extends route dependencies.
hub/​server/​routes/​index.ts Mounts agent and MCP routes.
hub/​server/​routes/​api/​security-audits/​present-security-audit/​index.ts Recognizes agent-connection audit actors.
hub/​server/​routes/​agent-connections/​types.ts Defines hosted learning configuration.
hub/​server/​routes/​agent-connections/​index.ts Implements connection management and MCP endpoints.
hub/​server/​routes/​agent-connections/​index.db.test.ts Tests OAuth approval and browser revocation.
hub/​server/​repositories/​agent-connections/​touch-agent-connection/​index.ts Updates token activity and inactivity limits.
hub/​server/​repositories/​agent-connections/​rotate-agent-connection/​index.ts Atomically rotates token digests.
hub/​server/​repositories/​agent-connections/​revoke-agent-connection/​index.ts Revokes connections by token or owner.
hub/​server/​repositories/​agent-connections/​record-agent-connection-audit/​index.ts Persists connection security audits.
hub/​server/​repositories/​agent-connections/​list-agent-connections/​index.ts Lists a person's connections.
hub/​server/​repositories/​agent-connections/​find-agent-repository/​index.ts Finds supported GitHub-backed repositories.
hub/​server/​repositories/​agent-connections/​create-agent-connection/​index.ts Persists approved agent credentials.
hub/​server/​repositories/​agent-clients/​find-agent-client/​index.ts Retrieves registered OAuth clients.
hub/​server/​repositories/​agent-clients/​create-agent-client/​index.ts Stores OAuth client registration.
hub/​server/​repositories/​agent-authorizations/​find-pending-agent-authorization/​index.ts Retrieves pending approval requests.
hub/​server/​repositories/​agent-authorizations/​find-agent-authorization-challenge/​index.ts Retrieves authorization-code PKCE challenges.
hub/​server/​repositories/​agent-authorizations/​decide-agent-authorization/​index.ts Settles approval requests once.
hub/​server/​repositories/​agent-authorizations/​create-agent-authorization/​index.ts Creates requests and removes expired ones.
hub/​server/​repositories/​agent-authorizations/​claim-agent-authorization/​index.ts Atomically consumes approved codes.
hub/​server/​integrations/​mcp/​require-agent-token/​index.ts Enforces bearer authentication and advertises discovery.
hub/​server/​integrations/​mcp/​handle-mcp-request/​index.ts Handles stateless MCP HTTP requests.
hub/​server/​integrations/​mcp/​handle-mcp-request/​index.test.ts Tests transport with parsed request bodies.
hub/​server/​integrations/​mcp/​create-agent-auth-router/​index.ts Adapts Hub connections to OAuth endpoints.
hub/​server/​integrations/​learning/​load-learning-mcp/​index.ts Loads package-provided MCP tools dynamically.
hub/​server/​integrations/​learning/​load-learning-mcp/​index.test.ts Tests package loading and error compatibility.
hub/​server/​integrations/​express/​canvas-sign-in-return/​index.ts Allows returning to agent approval after sign-in.
hub/​server/​index.ts Configures hosted agent connections at startup.
hub/​server/​domains/​agent-connections/​create-learning-mcp-backend/​index.ts Adapts learning tools to CLI operations.
hub/​server/​domains/​agent-connections/​create-agent-connections/​index.ts Implements connection and credential lifecycles.
hub/​server/​create-app/​index.ts Wires routes and protects browser endpoint payloads.
hub/​schema/​migrations/​20261223170000_agent_connections/​migration.sql Creates OAuth and connection persistence tables.
hub/​schema/​membership.prisma Relates memberships to agent connections.
hub/​schema/​hub-session.prisma Relates sessions to authorization requests.
hub/​schema/​external-identity.prisma Relates identities to agent connections.
hub/​schema/​authentication-provider-revision.prisma Relates provider revisions to connections.
hub/​schema/​agent-connection.prisma Defines connection credentials and authority references.
hub/​schema/​agent-client.prisma Defines registered OAuth clients.
hub/​schema/​agent-authorization.prisma Defines approval requests and one-time codes.
hub/​package.json Adds the MCP SDK dependency.
hub/​package-lock.json Locks MCP SDK dependencies.
hub/​docs/​learning-foundation.md Documents hosted connections, access, and limitations.
hub/​client/​pages/​learnings-page/​types.ts Adds the connection-page destination.
hub/​client/​pages/​learnings-page/​styles.css Arranges Learnings header actions.
hub/​client/​pages/​learnings-page/​stories.tsx Supplies connection navigation in stories.
hub/​client/​pages/​learnings-page/​index.tsx Adds the Connect an agent action.
hub/​client/​pages/​agent-connections-prototype/​types.ts Removes obsolete prototype data types.
hub/​client/​pages/​agent-connections-prototype/​index.test.tsx Removes prototype-only interaction tests.
hub/​client/​pages/​agent-connections-page/​types.ts Defines management and approval presentation data.
hub/​client/​pages/​agent-connections-page/​styles.css Removes obsolete simulated-result styling.
hub/​client/​pages/​agent-connections-page/​stories.tsx Updates connection and approval story states.
hub/​client/​pages/​agent-connections-page/​index.tsx Renders approval and revocation forms.
hub/​client/​pages/​agent-connections-page/​index.test.tsx Tests configuration copying and revocation confirmation.
hub/​client/​application/​hub/​view-models/​settings-learnings/​index.ts Supplies the agent-management link.
hub/​client/​application/​hub/​routes/​real-workspace-navigation.test.tsx Tests approval return paths through sign-in.
hub/​client/​application/​hub/​routes/​product-routes.ts Registers repository agent-management navigation.
hub/​client/​application/​hub/​routes/​learning-agents/​index.tsx Loads connections and submits revocations.
hub/​client/​application/​hub/​routes/​agent-approval/​index.tsx Loads approval requests and submits decisions.
hub/​client/​application/​hub/​routes.ts Registers the standalone approval route.
hub/​client/​application/​hub/​agent-connections/​contract.ts Validates connection API responses.
hub/​client/​application/​hub-application/​index.tsx Adds agent-specific sign-in wording.

Review effort: Max (adaptive)

Comment thread hub/server/create-app/index.ts Resolved
Comment thread hub/schema/agent-authorization.prisma Resolved
nshki and others added 10 commits November 25, 2026 23:32
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 25291e01-0146-42cb-ac6d-f5e1dd5c35f5
… routes

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 25291e01-0146-42cb-ac6d-f5e1dd5c35f5
Agent commands now share the learning execution lock, so they cannot overlap with
each other or with Learnings page work. Each command confirms the connection still
has repository access before its answer is returned. Private task text goes through
a temporary file instead of the process list.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 25291e01-0146-42cb-ac6d-f5e1dd5c35f5
…ss goes

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 25291e01-0146-42cb-ac6d-f5e1dd5c35f5
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 25291e01-0146-42cb-ac6d-f5e1dd5c35f5
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 25291e01-0146-42cb-ac6d-f5e1dd5c35f5
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 25291e01-0146-42cb-ac6d-f5e1dd5c35f5
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 25291e01-0146-42cb-ac6d-f5e1dd5c35f5
…ocation

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 25291e01-0146-42cb-ac6d-f5e1dd5c35f5
…elf-revocation

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 25291e01-0146-42cb-ac6d-f5e1dd5c35f5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants