@tpsdev-ai/flair 0.58.0 → 0.62.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -6
- package/SECURITY.md +36 -0
- package/config.yaml +15 -1
- package/dist/bridges/builtins/mem0.js +63 -28
- package/dist/bridges/runtime/import-runner.js +12 -0
- package/dist/bridges/runtime/load-plugin.js +42 -13
- package/dist/bridges/runtime/yaml-loader.js +4 -2
- package/dist/build-info.json +3 -3
- package/dist/cli.js +1030 -343
- package/dist/commands/agent.js +384 -45
- package/dist/commands/attention.js +4 -3
- package/dist/commands/backup.js +202 -34
- package/dist/commands/bridge.js +172 -119
- package/dist/commands/deploy.js +37 -4
- package/dist/commands/doctor.js +601 -163
- package/dist/commands/export.js +54 -19
- package/dist/commands/federation.js +141 -21
- package/dist/commands/hook.js +155 -2
- package/dist/commands/idp.js +14 -1
- package/dist/commands/import.js +7 -3
- package/dist/commands/init.js +462 -193
- package/dist/commands/integrity.js +388 -0
- package/dist/commands/keys.js +247 -58
- package/dist/commands/mcp.js +146 -53
- package/dist/commands/memory.js +171 -21
- package/dist/commands/migrate-harness-memory.js +3 -2
- package/dist/commands/orgevent.js +46 -37
- package/dist/commands/presence.js +4 -3
- package/dist/commands/principal.js +426 -48
- package/dist/commands/quality.js +10 -1
- package/dist/commands/reembed.js +141 -17
- package/dist/commands/relationship.js +2 -1
- package/dist/commands/rem.js +56 -18
- package/dist/commands/restore.js +101 -61
- package/dist/commands/search.js +6 -4
- package/dist/commands/service.js +151 -38
- package/dist/commands/soul.js +4 -3
- package/dist/commands/status.js +43 -5
- package/dist/commands/test.js +3 -2
- package/dist/commands/upgrade.js +24 -1
- package/dist/commands/workspace.js +6 -3
- package/dist/component-env.js +31 -41
- package/dist/deploy.js +77 -1
- package/dist/doctor-client.js +529 -92
- package/dist/engine-version-contract.js +1 -0
- package/dist/engine-version.js +23 -3
- package/dist/federation-verify.js +4 -3
- package/dist/hook-install.js +670 -6
- package/dist/keystore.js +72 -0
- package/dist/lib/action-recall-runtime.js +328 -0
- package/dist/lib/agent-home-fields.js +132 -0
- package/dist/lib/agent-home.js +427 -0
- package/dist/lib/agent-id-rule.js +46 -0
- package/dist/lib/agent-roster.js +33 -0
- package/dist/lib/auth-resolve.js +49 -16
- package/dist/lib/capture-runtime.js +124 -0
- package/dist/lib/credential-status-rule.js +78 -0
- package/dist/lib/daemon-liveness.js +81 -8
- package/dist/lib/doctor-run.js +140 -35
- package/dist/lib/durability-copy.js +10 -0
- package/dist/lib/embedding-space-doctor.js +75 -0
- package/dist/lib/flair-agent-role.js +120 -0
- package/dist/lib/hub-url.js +12 -0
- package/dist/lib/init-admin-pass.js +88 -12
- package/dist/lib/init-listener-environ.js +1 -2
- package/dist/lib/init-occupied-listener.js +15 -111
- package/dist/lib/init-spawn-attribution.js +73 -0
- package/dist/lib/init-tcp-probe.js +33 -0
- package/dist/lib/instance-identity-row.js +20 -0
- package/dist/lib/launchd-management.js +27 -2
- package/dist/lib/listener-table.js +268 -0
- package/dist/lib/local-delete-instance.js +27 -0
- package/dist/lib/local-instance-pair.js +256 -0
- package/dist/lib/mcp-enable.js +1775 -338
- package/dist/lib/mcp-oauth-env-core.js +133 -0
- package/dist/lib/mcp-oauth-env.js +125 -0
- package/dist/lib/mcp-spec.js +17 -1
- package/dist/lib/memory-attributes.js +2 -0
- package/dist/lib/memory-id-policy.js +46 -0
- package/dist/lib/memory-integrity.js +309 -0
- package/dist/lib/memory-purge-response.js +20 -0
- package/dist/lib/ops-table-count.js +25 -0
- package/dist/lib/owned-pins.js +67 -10
- package/dist/lib/peer-status.js +27 -0
- package/dist/lib/principal-status.js +29 -0
- package/dist/lib/process-start-time.js +103 -7
- package/dist/lib/proto-safe-record.js +42 -0
- package/dist/lib/record-id-path.js +25 -0
- package/dist/lib/reembed-server-support.js +66 -0
- package/dist/lib/restore-verify.js +104 -0
- package/dist/lib/scheduler-platform.js +10 -6
- package/dist/lib/secret-keys.js +25 -0
- package/dist/lib/secrets-push.js +50 -22
- package/dist/lib/skill-seed-pending.js +24 -0
- package/dist/lib/skill-seed.js +365 -0
- package/dist/lib/stop-start-recovery.js +54 -0
- package/dist/lib/using-flair-skill.js +87 -0
- package/dist/mcp-client-assertion.js +112 -4
- package/dist/memory-id-checkpoint.js +326 -0
- package/dist/memory-node-compare.js +207 -0
- package/dist/packages/flair-mcp/src/secret-redaction.js +113 -0
- package/dist/rem/restore.js +6 -5
- package/dist/rem/runner.js +103 -44
- package/dist/resources/Agent.js +348 -8
- package/dist/resources/AgentKeyRegister.js +214 -0
- package/dist/resources/AgentKeyRegistration.js +28 -0
- package/dist/resources/AgentSeed.js +19 -4
- package/dist/resources/AutoPromoteCandidates.js +7 -1
- package/dist/resources/Credential.js +177 -2
- package/dist/resources/Federation.js +752 -132
- package/dist/resources/FederationRetry.js +140 -0
- package/dist/resources/InstructionVersion.js +220 -0
- package/dist/resources/Integration.js +300 -25
- package/dist/resources/Memory.js +2113 -604
- package/dist/resources/MemoryArchive.js +75 -42
- package/dist/resources/MemoryBootstrap.js +227 -64
- package/dist/resources/MemoryCandidate.js +21 -1
- package/dist/resources/MemoryDedupStats.js +30 -1
- package/dist/resources/MemoryFeed.js +327 -45
- package/dist/resources/MemoryGrant.js +21 -1
- package/dist/resources/MemoryMaintenance.js +129 -25
- package/dist/resources/MemoryPurge.js +232 -0
- package/dist/resources/MemoryReflect.js +7 -2
- package/dist/resources/MemoryReindex.js +24 -8
- package/dist/resources/Message.js +5 -3
- package/dist/resources/OAuth.js +186 -9
- package/dist/resources/OrgEvent.js +126 -3
- package/dist/resources/OrgSkillAssignment.js +209 -0
- package/dist/resources/Presence.js +144 -49
- package/dist/resources/PromoteMemoryCandidate.js +18 -7
- package/dist/resources/Relationship.js +23 -0
- package/dist/resources/SemanticSearch.js +63 -32
- package/dist/resources/Soul.js +189 -76
- package/dist/resources/TeamDirectory.js +35 -0
- package/dist/resources/WorkspaceState.js +21 -1
- package/dist/resources/XAA.js +212 -65
- package/dist/resources/agent-auth.js +40 -15
- package/dist/resources/agent-status-guard.js +63 -0
- package/dist/resources/auth-middleware.js +402 -162
- package/dist/resources/ed25519-auth.js +1 -1
- package/dist/resources/embedding-space-guard.js +366 -72
- package/dist/resources/engine-version-stamp-boot.js +53 -0
- package/dist/resources/federation-classify.js +94 -0
- package/dist/resources/federation-crypto.js +5 -5
- package/dist/resources/federation-retry-lib.js +135 -0
- package/dist/resources/flair-agent-role-boot.js +26 -0
- package/dist/resources/grant-visibility.js +135 -0
- package/dist/resources/harper-routing.js +83 -0
- package/dist/resources/health.js +130 -20
- package/dist/resources/host-source-citation.js +49 -0
- package/dist/resources/host-source-visibility.js +7 -6
- package/dist/resources/instance-create-lock.js +17 -0
- package/dist/resources/instance-identity.js +23 -0
- package/dist/resources/instruction-version-record.js +343 -0
- package/dist/resources/key-lock.js +31 -0
- package/dist/resources/mcp-handler.js +36 -8
- package/dist/resources/mcp-oauth-env-guard.js +36 -0
- package/dist/resources/mcp-oauth.js +26 -12
- package/dist/resources/mcp-tool-arguments.js +4 -6
- package/dist/resources/mcp-tools.js +150 -23
- package/dist/resources/memory-bootstrap-lib.js +5 -15
- package/dist/resources/memory-declared-attributes.js +3 -1
- package/dist/resources/memory-deletion-history.js +55 -0
- package/dist/resources/memory-durability.js +54 -0
- package/dist/resources/memory-embed-hash.js +88 -0
- package/dist/resources/memory-embedding-value.js +8 -0
- package/dist/resources/memory-host-source.js +27 -5
- package/dist/resources/memory-id-guard.js +75 -0
- package/dist/resources/memory-redaction.js +236 -0
- package/dist/resources/memory-supplied-vector.js +72 -0
- package/dist/resources/memory-write-lock.js +310 -0
- package/dist/resources/memory-write-response.js +139 -0
- package/dist/resources/migrations/data-dir.js +74 -16
- package/dist/resources/migrations/dir-safety.js +1 -1
- package/dist/resources/migrations/embedding-stamp.js +193 -79
- package/dist/resources/migrations/export.js +1 -0
- package/dist/resources/migrations/graph-heal.js +18 -25
- package/dist/resources/migrations/lock.js +7 -1
- package/dist/resources/migrations/snapshot.js +1 -0
- package/dist/resources/migrations/source-fields.js +5 -5
- package/dist/resources/migrations/synthetic-test-migration.js +14 -11
- package/dist/resources/migrations/visibility-backfill.js +29 -29
- package/dist/resources/multi-worker-guard.js +121 -0
- package/dist/resources/oauth-discovery.js +1 -0
- package/dist/resources/oauth-wellknown.js +8 -4
- package/dist/resources/object-body-guard.js +33 -0
- package/dist/resources/org-event-created-at.js +133 -0
- package/dist/resources/originator-instance.js +39 -7
- package/dist/resources/owner-delete-recheck.js +78 -0
- package/dist/resources/owner-field-guard.js +39 -5
- package/dist/resources/owner-scoped-write-policy.js +212 -0
- package/dist/resources/owner-scoped-writes.js +58 -0
- package/dist/resources/presence-receipt.js +236 -0
- package/dist/resources/promotion-stamp.js +47 -12
- package/dist/resources/record-owner-guard.js +74 -26
- package/dist/resources/record-types.js +17 -1
- package/dist/resources/relay-ops.js +78 -6
- package/dist/resources/replay-store.js +145 -21
- package/dist/resources/request-target.js +136 -0
- package/dist/resources/request-transaction.js +35 -0
- package/dist/resources/search-readiness.js +4 -1
- package/dist/resources/seed-ids.js +9 -0
- package/dist/resources/seed-reservation.js +117 -0
- package/dist/resources/semantic-retrieval-core.js +20 -9
- package/dist/resources/skill-manifest.js +190 -0
- package/dist/resources/skill-provenance.js +15 -10
- package/dist/resources/skill-subject.js +53 -0
- package/dist/resources/skill-version-write.js +432 -0
- package/dist/resources/skill-write-fault.js +17 -0
- package/dist/resources/skill-write-policy.js +67 -0
- package/dist/resources/skill-write.js +67 -7
- package/dist/resources/table-helpers.js +10 -7
- package/dist/resources/team-directory.js +248 -0
- package/dist/resources/tool-descriptors/index.js +69 -8
- package/dist/resources/txn-pause-point.js +118 -0
- package/dist/resources/usage-recording.js +171 -63
- package/dist/resources/write-back.js +218 -0
- package/dist/src/engine-version-contract.js +1 -0
- package/dist/src/keystore.js +72 -0
- package/dist/src/lib/agent-home-fields.js +132 -0
- package/dist/src/lib/agent-id-rule.js +46 -0
- package/dist/src/lib/agent-key-register.js +80 -0
- package/dist/src/lib/atomic-write.js +256 -0
- package/dist/src/lib/credential-status-rule.js +78 -0
- package/dist/src/lib/expired-by-agent.js +37 -0
- package/dist/src/lib/flair-agent-role.js +120 -0
- package/dist/src/lib/idp-mapping-rule.js +81 -0
- package/dist/src/lib/instance-identity-row.js +20 -0
- package/dist/src/lib/mcp-oauth-env-core.js +133 -0
- package/dist/src/lib/memory-attributes.js +2 -0
- package/dist/src/lib/memory-id-policy.js +46 -0
- package/dist/src/lib/principal-status.js +29 -0
- package/dist/src/lib/proto-safe-record.js +42 -0
- package/dist/src/lib/reembed-server-support.js +66 -0
- package/dist/src/lib/scheduler-platform.js +10 -6
- package/dist/src/lib/systemd-agent-id.js +38 -0
- package/docs/access-control.md +768 -0
- package/docs/api-reference.md +52 -13
- package/docs/auth.md +10 -12
- package/docs/bridges.md +11 -0
- package/docs/claude-code.md +34 -4
- package/docs/deepseek-harness.md +1 -1
- package/docs/deploying-on-fabric.md +70 -0
- package/docs/deployment.md +2 -0
- package/docs/embedding-in-a-harper-app.md +1 -1
- package/docs/federation.md +33 -2
- package/docs/hosted-on-fabric.md +43 -36
- package/docs/integrations.md +6 -6
- package/docs/mcp-clients.md +10 -5
- package/docs/n8n.md +17 -11
- package/docs/notes/mcp-agent-auth-consumer.md +12 -4
- package/docs/notes/mcp-oauth-model2.md +34 -5
- package/docs/quickstart-fabric.md +2 -2
- package/docs/quickstart.md +9 -1
- package/docs/releasing.md +34 -28
- package/docs/rem.md +8 -0
- package/docs/secrets-and-keys.md +19 -2
- package/docs/standalone-local.md +1 -0
- package/docs/supply-chain-policy.md +13 -3
- package/docs/upgrade.md +32 -6
- package/package.json +12 -6
- package/schemas/agent-key-registration.graphql +22 -0
- package/schemas/agent.graphql +3 -0
- package/schemas/federation.graphql +38 -1
- package/schemas/memory.graphql +115 -5
- package/schemas/oauth.graphql +27 -4
- package/schemas/schema.graphql +2 -0
- package/templates/launchd/start-flair-with-admin-pass.sh +89 -16
|
@@ -0,0 +1,768 @@
|
|
|
1
|
+
# Who can connect to your Flair
|
|
2
|
+
|
|
3
|
+
Three separate checks decide who can use the native `/mcp` endpoint of a hosted
|
|
4
|
+
Flair. **Which people:** a person signs in at your identity provider, and Flair
|
|
5
|
+
acts as the principal that login is mapped to. A login with no mapping cannot
|
|
6
|
+
call tools, unless you turn on just-in-time provisioning (off by default), which
|
|
7
|
+
creates a principal for it. **Which apps:** new apps identify themselves with a
|
|
8
|
+
Client ID Metadata Document, and the shipped `allowedHosts` list (`claude.ai`
|
|
9
|
+
and `claude.com`) limits which hosts may serve one. Registration of new clients
|
|
10
|
+
is off; clients registered while it was on keep using their stored client IDs
|
|
11
|
+
until their records are removed. **What they can touch:** a connection acts as
|
|
12
|
+
its principal. For a non-admin principal, that means writing its own memories
|
|
13
|
+
and reading them plus other agents' non-private ones. `flair principal disable`
|
|
14
|
+
marks a principal deactivated, which refuses its tool calls and keeps its data.
|
|
15
|
+
|
|
16
|
+
This page covers `/mcp`, where apps such as Claude sign people in with OAuth.
|
|
17
|
+
Agents that sign each request with their own Ed25519 key use a different path,
|
|
18
|
+
described in [auth.md](auth.md#ed25519-agent-auth-default) and in
|
|
19
|
+
[worked example 4](#4-a-bot-on-another-host-signs-with-its-own-key). How `/mcp`
|
|
20
|
+
is turned on is in [mcp-clients.md — Two MCP paths](mcp-clients.md#two-mcp-paths).
|
|
21
|
+
|
|
22
|
+
## 1. Which people
|
|
23
|
+
|
|
24
|
+
When someone connects an app, the app sends them to Flair's authorization
|
|
25
|
+
server, which has them sign in at the identity provider configured under
|
|
26
|
+
`'@harperfast/oauth'` → `providers` in Flair's `config.yaml`. The shipped file
|
|
27
|
+
configures GitHub. The access token the app receives carries the login as its
|
|
28
|
+
subject; for GitHub, that is the account's username.
|
|
29
|
+
|
|
30
|
+
`/mcp` answers `initialize`, `ping` and `tools/list` for any valid token, and
|
|
31
|
+
refuses a `tools/call` for an unknown tool name, before it looks at the mapping.
|
|
32
|
+
On a `tools/call` for a known tool, Flair looks for a `Credential` of kind `idp`
|
|
33
|
+
whose `idpSubject` is that login, that names a principal, and whose status is
|
|
34
|
+
not `revoked`, and acts as that principal. There is no fallback to an anonymous
|
|
35
|
+
or admin identity:
|
|
36
|
+
|
|
37
|
+
- **No mapping:** the call is refused. `/mcp` answers HTTP 200 with a JSON-RPC
|
|
38
|
+
error:
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{"jsonrpc":"2.0","id":1,"error":{"code":-32001,"message":"forbidden: token subject is not a provisioned flair agent"}}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
- **Mapped to a principal that does not exist:** refused with code `-32001` and
|
|
45
|
+
a message naming the principal.
|
|
46
|
+
- **Mapped to a deactivated principal:** refused; see
|
|
47
|
+
[Revoking access](#revoking-access).
|
|
48
|
+
- **The credential or the principal could not be read:** refused with code
|
|
49
|
+
`-32000` and a message starting `unavailable:`.
|
|
50
|
+
|
|
51
|
+
### Map a person to a principal
|
|
52
|
+
|
|
53
|
+
`flair mcp enable` writes the mapping in its `identity-mapping` step:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
flair mcp enable \
|
|
57
|
+
--instance https://flair.example.com \
|
|
58
|
+
--idp-subject alice \
|
|
59
|
+
--principal alice \
|
|
60
|
+
--admin-pass "$TARGET_ADMIN_PASS"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
- `--idp-subject` is the login the identity provider reports: for GitHub, the
|
|
64
|
+
username.
|
|
65
|
+
- `--principal` is the principal the connector identity maps to. It defaults
|
|
66
|
+
to `self`. If no principal with that id
|
|
67
|
+
exists, the step creates a non-admin one, of kind `human` unless you pass
|
|
68
|
+
`--principal-kind agent`.
|
|
69
|
+
- `--admin-pass` is the target instance's admin password. Outside `--dry-run`,
|
|
70
|
+
this command does not fall back to `FLAIR_ADMIN_PASS` or
|
|
71
|
+
`~/.flair/admin-pass`. It writes the mapping through the target's operations
|
|
72
|
+
API on port 9925 of the `--instance` host. <!-- docs-freshness-allow: hosted operations API port, not the data port -->
|
|
73
|
+
- In a terminal, and outside `--dry-run`, it prompts for the GitHub OAuth app's
|
|
74
|
+
client id and secret when `--idp-client-id` and `--idp-client-secret` are not
|
|
75
|
+
passed.
|
|
76
|
+
|
|
77
|
+
The step's output states the mapping it wrote. The line starts:
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
connector identity: mapped sub 'alice' (provider 'github') to Agent 'alice'; see docs/access-control.md for how /mcp tool calls use it. principal created; Credential(kind:idp) created (cred_idp_github_<12 hex digits>).
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`flair mcp enable` runs the whole enablement flow, not only this step. To add a
|
|
84
|
+
person to an instance that is already enabled, also pass
|
|
85
|
+
`--secrets-mechanism env-file`, so that the secrets it stages go to a local
|
|
86
|
+
`0600` file and are not sent to the instance. Then answer `n` when it asks
|
|
87
|
+
whether the staged secrets are applied. The `identity-mapping` step has run by
|
|
88
|
+
then; a ✓ on it in the printed steps means the write was accepted and the
|
|
89
|
+
read-back described under [One mapping per login](#one-mapping-per-login)
|
|
90
|
+
passed. The command stops before restarting the instance, reports the
|
|
91
|
+
`secrets-provisioning` step as not applied, and exits non-zero.
|
|
92
|
+
|
|
93
|
+
### Link or unlink one login
|
|
94
|
+
|
|
95
|
+
`flair principal link` does only the mapping step, on an instance that is
|
|
96
|
+
already enabled:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
flair principal link alice --instance https://flair.example.com \
|
|
100
|
+
--idp-subject alice --admin-pass "$TARGET_ADMIN_PASS"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The principal must already exist: a missing one is refused by name. A subject
|
|
104
|
+
already mapped to that principal is reported with nothing written; a subject
|
|
105
|
+
mapped to a different principal is refused unless `--replace` moves it, which
|
|
106
|
+
prints the prior principal and any superseded credential. More than one active
|
|
107
|
+
principal mapped to the subject is refused before writing.
|
|
108
|
+
`--instance` (else `FLAIR_URL`) must be HTTPS: these commands
|
|
109
|
+
send the target's admin credential to its operations API, which on a hosted
|
|
110
|
+
instance is the instance host at port 9925. <!-- docs-freshness-allow: hosted operations API port, not the data port -->
|
|
111
|
+
An unparseable URL, `localhost`, a `.local` name, or a loopback, unspecified,
|
|
112
|
+
RFC1918, link-local or IPv6 unique-local address literal is refused before any
|
|
113
|
+
request, and a REMOTE target gets no `--admin-pass` fallback (the rule
|
|
114
|
+
`flair mcp enable` applies).
|
|
115
|
+
|
|
116
|
+
`flair principal unlink <principal> --idp-subject <login>` defaults to provider
|
|
117
|
+
`github`; pass `--idp-provider <name>` for a different provider. Unlink reports
|
|
118
|
+
success only after confirmed updates and no resolvable subject mapping on
|
|
119
|
+
readback. With `FLAIR_MCP_JIT_PROVISION` on, a known tool call after an
|
|
120
|
+
unmapped login may provision a new principal.
|
|
121
|
+
`flair principal links <principal>` lists a principal's current mappings, and
|
|
122
|
+
both take the same `--instance` and `--admin-pass`.
|
|
123
|
+
|
|
124
|
+
### One mapping per login
|
|
125
|
+
|
|
126
|
+
`flair mcp enable` and the resolver both count a login's `idp` credential unless
|
|
127
|
+
its status is `revoked` (the resolver also skips one that names no principal).
|
|
128
|
+
`flair mcp enable` keeps one such credential per login, whatever the provider
|
|
129
|
+
name:
|
|
130
|
+
|
|
131
|
+
- Running it again with the same `--idp-subject` and `--idp-provider` and a
|
|
132
|
+
different `--principal` re-points the existing credential, and the output
|
|
133
|
+
says `re-pointed`. Calls from that login then act as the principal the
|
|
134
|
+
credential names. Memories are not moved or merged; each principal keeps its
|
|
135
|
+
own.
|
|
136
|
+
- If the login has a credential that is not `revoked` under a different
|
|
137
|
+
provider name, the run revokes it (the row stays, with status `revoked`) and
|
|
138
|
+
prints its id after `SUPERSEDED:`.
|
|
139
|
+
- After writing, it requires exactly one resolvable (principal-bearing) active
|
|
140
|
+
credential matching the written id and principal.
|
|
141
|
+
Principal-less legacy rows are skipped and may remain active.
|
|
142
|
+
|
|
143
|
+
### Who writes a mapping
|
|
144
|
+
|
|
145
|
+
Through the `Credential` resource, only an administrator or Flair itself
|
|
146
|
+
creates an `idp` credential, changes its kind or identity fields, or
|
|
147
|
+
reactivates it. Flair writes mappings through `flair mcp enable`,
|
|
148
|
+
`flair principal link` and `unlink`, and just-in-time provisioning (below, and
|
|
149
|
+
the XAA grant's); an administrator can also write one through the `Credential`
|
|
150
|
+
resource.
|
|
151
|
+
|
|
152
|
+
On POST, PUT and PATCH, the checks that run first decide before this rule:
|
|
153
|
+
authentication, the owner checks, and the request checks (the rate limit and
|
|
154
|
+
kind validation on POST and PUT, the single-record body on PATCH). For a
|
|
155
|
+
non-admin agent, the owner checks keep their own 403: on PATCH and PUT the
|
|
156
|
+
owner-field guard refuses a change to the credential's principal, PUT refuses
|
|
157
|
+
a body that names another principal, and PATCH, PUT and DELETE refuse a write
|
|
158
|
+
to another principal's credential. On POST, a non-admin agent's credential is
|
|
159
|
+
stamped with its own principal; a `principalId` in the body is not used. An
|
|
160
|
+
administrator may write another principal's credential. A non-admin agent's
|
|
161
|
+
write that passes those checks gets HTTP 403
|
|
162
|
+
with the error `idp_mapping_admin_only` when it would create an `idp`
|
|
163
|
+
credential, change a credential's kind to or from `idp`, change an `idp`
|
|
164
|
+
credential's provider or subject, or change its status to anything other than
|
|
165
|
+
`revoked` (so it cannot reactivate one). A non-admin agent may relabel its own
|
|
166
|
+
`idp` credential, set its status to `revoked`, and delete it.
|
|
167
|
+
|
|
168
|
+
### Just-in-time provisioning
|
|
169
|
+
|
|
170
|
+
`FLAIR_MCP_JIT_PROVISION` is off by default; `1`, `true`, `yes` or `on` turns
|
|
171
|
+
it on. It changes the "no mapping" case: instead of refusing, Flair creates a
|
|
172
|
+
principal for the login on its first call to a known tool and maps the login to
|
|
173
|
+
it (if that write fails, the call is refused as in the "no mapping" case). The
|
|
174
|
+
new principal is a non-admin agent with trust tier `unverified`, and its id has
|
|
175
|
+
the form `agt_mcp_<login>_<8 hex digits>`, where characters other than letters
|
|
176
|
+
and digits become `_` and the login part is cut to 24 characters. Its
|
|
177
|
+
credential records the provider as `mcp-oauth`.
|
|
178
|
+
|
|
179
|
+
Flair adds no check of its own in this mode: a login the authorization server
|
|
180
|
+
issued a token for gets a principal on its first call to a known tool. Flair's
|
|
181
|
+
shipped configuration does not restrict which GitHub accounts can sign in. Turn
|
|
182
|
+
it on only when that is what you want, and set it in the instance's process
|
|
183
|
+
environment, like `FLAIR_MCP_OAUTH`.
|
|
184
|
+
|
|
185
|
+
## 2. Which apps
|
|
186
|
+
|
|
187
|
+
New apps identify themselves with a Client ID Metadata Document (CIMD): the
|
|
188
|
+
`client_id` is an HTTPS URL, and Flair's authorization server fetches the
|
|
189
|
+
document from that URL, and caches it, when a person starts to sign in. Clients
|
|
190
|
+
registered before registration was turned off use their stored client IDs
|
|
191
|
+
instead (see below).
|
|
192
|
+
|
|
193
|
+
- **Registration of new clients is off.** The shipped `config.yaml` sets
|
|
194
|
+
`dynamicClientRegistration.enabled: false`, so `POST /oauth/mcp/register`
|
|
195
|
+
answers `404 {"error":"Not found"}`, and the metadata at
|
|
196
|
+
`/.well-known/oauth-authorization-server` lists no `registration_endpoint`.
|
|
197
|
+
- **Clients registered earlier stay usable.** A `client_id` that is not shaped
|
|
198
|
+
like a metadata-document URL is looked up among stored registrations, in the
|
|
199
|
+
`harper_oauth_mcp_clients` table of Harper's `oauth` database. Turning
|
|
200
|
+
registration off does not remove those records: a client registered while
|
|
201
|
+
registration was on can still sign people in and refresh tokens, and the host
|
|
202
|
+
list below does not apply to it. Flair has no command that lists or removes
|
|
203
|
+
these records; such a client stays usable until its record is deleted.
|
|
204
|
+
- **Listed hosts.** When `clientIdMetadataDocuments.allowedHosts` is non-empty,
|
|
205
|
+
a `client_id` URL is accepted only if its host is on the list. For the
|
|
206
|
+
document of an app that signs people in, an empty list (`[]`) or no
|
|
207
|
+
`allowedHosts` key adds no allowlist restriction. The plugin still resolves
|
|
208
|
+
the host before fetching and refuses one that resolves to an address outside
|
|
209
|
+
the public ranges, such as a private, loopback or link-local address. A
|
|
210
|
+
headless (`client_credentials`) document is refused unless the list is
|
|
211
|
+
non-empty; with the shipped `config.yaml`, Flair's authorization server does
|
|
212
|
+
not take that grant at all (see [example 5](#5-a-bot-reaches-another-oauth-protected-mcp-server-as-itself)).
|
|
213
|
+
The shipped list, `claude.ai` and `claude.com`, is there for Claude. With a
|
|
214
|
+
non-empty list, a `client_id` on any other host gets HTTP 400 from the
|
|
215
|
+
authorization endpoint, with error `invalid_client` and the description
|
|
216
|
+
`Unknown client_id`.
|
|
217
|
+
- **The person sees the app's host.** For an app that uses a metadata document,
|
|
218
|
+
the authorization server shows a page naming the host of the app's
|
|
219
|
+
`client_id` before it sends the person to the identity provider; the person
|
|
220
|
+
continues from there.
|
|
221
|
+
- **Public clients with PKCE.** The document of an app that signs people in
|
|
222
|
+
may declare its token endpoint auth method. With the shipped `config.yaml` it
|
|
223
|
+
must be `token_endpoint_auth_method: none`, or the field left out; any other
|
|
224
|
+
value is refused with `invalid_client`. Every authorization request must
|
|
225
|
+
carry a PKCE `code_challenge` with method `S256`. With MCP enabled and a
|
|
226
|
+
provider configured, the shipped server advertises `none`,
|
|
227
|
+
`client_secret_basic` and `client_secret_post` as token endpoint auth methods (the last two apply only to registered clients)
|
|
228
|
+
and does not advertise `private_key_jwt`. Setting
|
|
229
|
+
`mcp.clientCredentials.enabled: true`, which turns on the headless grant,
|
|
230
|
+
changes the metadata: it then also lists `private_key_jwt`, the
|
|
231
|
+
`client_credentials` grant type and `RS256`, `ES256` and `EdDSA` as the
|
|
232
|
+
assertion signing algorithms. Setting
|
|
233
|
+
`mcp.clientIdMetadataDocuments.privateKeyJwt.enabled: true` also lists
|
|
234
|
+
`private_key_jwt` and those three algorithms. With either setting, a document
|
|
235
|
+
may declare `private_key_jwt` (with usable keys) instead of `none`.
|
|
236
|
+
|
|
237
|
+
### Changing the list
|
|
238
|
+
|
|
239
|
+
The list lives in `config.yaml`:
|
|
240
|
+
|
|
241
|
+
```yaml
|
|
242
|
+
'@harperfast/oauth':
|
|
243
|
+
mcp:
|
|
244
|
+
clientIdMetadataDocuments:
|
|
245
|
+
allowedHosts:
|
|
246
|
+
- claude.ai
|
|
247
|
+
- claude.com
|
|
248
|
+
- apps.example.com
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Edit the `config.yaml` your instance runs (on Fabric, the one you deploy) and
|
|
252
|
+
restart Flair so the component loads the new list. The list is a literal in that
|
|
253
|
+
file, not an environment reference. The package ships the file with the default
|
|
254
|
+
list, and a completed upgrade installs the new version's file, so re-apply your
|
|
255
|
+
edit after upgrading.
|
|
256
|
+
|
|
257
|
+
`flair mcp enable --cimd-allowed-hosts <hosts>` can make this edit to
|
|
258
|
+
`config.yaml` in the current directory, else `~/.flair/config.yaml`, on the
|
|
259
|
+
machine where you run it. Without `--dry-run`, before any step that changes
|
|
260
|
+
anything, it refuses the flag unless a preflight match links the host and
|
|
261
|
+
process ID the instance reports, a readable process on this machine, and that
|
|
262
|
+
file (compared by `realpath`). At its `local-config-update` step, before it
|
|
263
|
+
restarts the instance, it writes the list unless the file already holds that
|
|
264
|
+
exact list, then reads the file back. It also refuses the flag for a Fabric
|
|
265
|
+
instance, an invalid host list, or a `config.yaml` that is missing, unreadable
|
|
266
|
+
or not valid YAML, or has no `@harperfast/oauth` `mcp` mapping; it does not
|
|
267
|
+
check early that the file can be written, and a write failure fails the later
|
|
268
|
+
`local-config-update` step. A refusal changes nothing. With `--dry-run`, it
|
|
269
|
+
skips the match and writes nothing. A run that stops before
|
|
270
|
+
`local-config-update` does not write the list.
|
|
271
|
+
On Fabric, and whenever the command refuses, edit the file by hand as above. If
|
|
272
|
+
an upgrade replaces that file, run the command again or edit the file.
|
|
273
|
+
|
|
274
|
+
### ChatGPT
|
|
275
|
+
|
|
276
|
+
With MCP enabled and a provider configured, admitting ChatGPT's CIMD client
|
|
277
|
+
requires `chatgpt.com` in `mcp.clientIdMetadataDocuments.allowedHosts` and
|
|
278
|
+
`mcp.clientIdMetadataDocuments.privateKeyJwt.enabled: true`. ChatGPT's assertion
|
|
279
|
+
uses the token-endpoint URL as its audience, so the pinned `@harperfast/oauth`
|
|
280
|
+
2.9.0 also requires this exception in the deployed `config.yaml`:
|
|
281
|
+
|
|
282
|
+
```yaml
|
|
283
|
+
'@harperfast/oauth':
|
|
284
|
+
mcp:
|
|
285
|
+
clientIdMetadataDocuments:
|
|
286
|
+
allowedHosts:
|
|
287
|
+
- claude.ai
|
|
288
|
+
- claude.com
|
|
289
|
+
- chatgpt.com
|
|
290
|
+
privateKeyJwt:
|
|
291
|
+
enabled: true
|
|
292
|
+
tokenEndpointAudience:
|
|
293
|
+
clientIds:
|
|
294
|
+
- https://chatgpt.com/oauth/client.json
|
|
295
|
+
expiresAt: '2026-11-01T00:00:00Z'
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
Use the exact client ID and an operator-chosen future ISO 8601 `expiresAt`;
|
|
299
|
+
the exception stops accepting the token-endpoint audience at that expiry.
|
|
300
|
+
Restart Flair after editing the configuration.
|
|
301
|
+
|
|
302
|
+
## 3. What they can touch
|
|
303
|
+
|
|
304
|
+
A connection acts as its principal:
|
|
305
|
+
|
|
306
|
+
- **Writes** go under the principal's id. A non-admin principal cannot write a
|
|
307
|
+
memory owned by another agent
|
|
308
|
+
(`forbidden: cannot write memory owned by another agent`). The identity comes
|
|
309
|
+
from the login's mapping, never from tool arguments.
|
|
310
|
+
- **Reads** cover the principal's own memories, of any visibility, and every
|
|
311
|
+
other agent's memories on the instance that are not `private`. A non-admin
|
|
312
|
+
principal does not get other agents' `private` memories. `flair grant` does
|
|
313
|
+
not change this, because reads do not consult memory grants.
|
|
314
|
+
- **Admin** authority applies to a `/mcp` connection only when the principal's
|
|
315
|
+
Agent record has `role: admin`. The principals that `flair mcp enable` and
|
|
316
|
+
just-in-time provisioning create are not admins.
|
|
317
|
+
|
|
318
|
+
### Tokens
|
|
319
|
+
|
|
320
|
+
- With the shipped `config.yaml` (`accessTokenTtl: 900`), an access token from
|
|
321
|
+
the authorization-code grant, or from refreshing one, lasts 900 seconds. When
|
|
322
|
+
the headless `client_credentials` grant is enabled, its access tokens last
|
|
323
|
+
300 seconds unless `mcp.clientCredentials.accessTokenTtl` is set. A request
|
|
324
|
+
with an expired or invalid token gets HTTP 401 with
|
|
325
|
+
error `invalid_token` and a `WWW-Authenticate: Bearer resource_metadata="…"`
|
|
326
|
+
header.
|
|
327
|
+
- With the shipped `config.yaml`, which does not set
|
|
328
|
+
`mcp.refreshTokenRequiresOfflineAccess`, the app also gets a refresh token
|
|
329
|
+
unless its metadata lists grant types without `refresh_token`. When that
|
|
330
|
+
option is set to true, the granted scope must also include `offline_access`.
|
|
331
|
+
Refresh tokens are single-use: each refresh returns a
|
|
332
|
+
new one. A refresh token that was already used is refused (`invalid_grant`),
|
|
333
|
+
and the plugin attempts to revoke that sign-in's whole refresh-token family;
|
|
334
|
+
if that revocation write fails, the failure is logged and the token is still
|
|
335
|
+
refused. The family expires 30 days after the sign-in, the
|
|
336
|
+
`@harperfast/oauth` default; the shipped `config.yaml` does not set
|
|
337
|
+
`refreshTokenTtl`.
|
|
338
|
+
|
|
339
|
+
### Revoking access
|
|
340
|
+
|
|
341
|
+
Deactivate or reactivate a local principal with `FLAIR_ADMIN_PASS` set or
|
|
342
|
+
`--admin-pass` (and neither `--instance` nor `FLAIR_URL` set):
|
|
343
|
+
|
|
344
|
+
```bash
|
|
345
|
+
flair principal disable alice
|
|
346
|
+
flair principal enable alice
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
For a principal on a remote instance, pass the instance URL and its admin
|
|
350
|
+
password explicitly. These commands share two precedence and credential rules
|
|
351
|
+
with `flair mcp enable`: an explicit `--instance` wins over `FLAIR_URL`, and a
|
|
352
|
+
remote operation requires an explicit `--admin-pass`. The principal commands accept
|
|
353
|
+
explicit loopback targets; `flair mcp enable` accepts loopback or unspecified targets
|
|
354
|
+
for the local restart but refuses local issuers.
|
|
355
|
+
|
|
356
|
+
```bash
|
|
357
|
+
flair principal disable alice \
|
|
358
|
+
--instance https://flair.example.com \
|
|
359
|
+
--admin-pass "$TARGET_ADMIN_PASS"
|
|
360
|
+
flair principal enable alice \
|
|
361
|
+
--instance https://flair.example.com \
|
|
362
|
+
--admin-pass "$TARGET_ADMIN_PASS"
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
Set `TARGET_ADMIN_PASS` to that instance's admin password before running the
|
|
366
|
+
remote example. A success line appears only after the command reads `alice`,
|
|
367
|
+
the operations API names it in the update result, and a read-back shows the
|
|
368
|
+
requested status; the line reports that read-back status.
|
|
369
|
+
|
|
370
|
+
- On the local path it sends an `update` to the operations API at `127.0.0.1`
|
|
371
|
+
on the machine it runs on. The port precedence is a valid explicit
|
|
372
|
+
`--ops-port`, then `FLAIR_OPS_PORT`, then `opsPort` in the local Flair config,
|
|
373
|
+
then one less than the resolved HTTP port. An invalid explicit `--ops-port`
|
|
374
|
+
is refused with a remedy; it never falls through to a lower-precedence port.
|
|
375
|
+
- With `--instance` (or `FLAIR_URL`) it sends the same `update` to the ops API
|
|
376
|
+
derived from that served instance URL, using the `flair mcp enable` hosted
|
|
377
|
+
operations port convention. A remote target requires an explicit
|
|
378
|
+
`--admin-pass`: `FLAIR_ADMIN_PASS` and `~/.flair/admin-pass` are
|
|
379
|
+
this machine's local credentials and are never sent to another instance.
|
|
380
|
+
`FLAIR_TARGET` and `FLAIR_OPS_TARGET` do not select a principal target.
|
|
381
|
+
Redirects, unconfirmed results, and requests that fail or time out are
|
|
382
|
+
refused with a non-zero exit. Diagnostics omit URL userinfo, query values,
|
|
383
|
+
and unexpected response values; an unparseable target is printed only as
|
|
384
|
+
`<unparseable URL>`.
|
|
385
|
+
- Disable sets the principal's `status` to `deactivated`; enable sets it to
|
|
386
|
+
`active`. Both update its `updatedAt` and nothing else: the principal's
|
|
387
|
+
memories and its login mapping stay. Harper can accept an update for an id
|
|
388
|
+
that has no record, so the command reads the principal first and refuses
|
|
389
|
+
`no principal <id>` before any update when no row exists; a read that fails
|
|
390
|
+
or returns an unreadable body is refused as unverified rather than as
|
|
391
|
+
missing.
|
|
392
|
+
- Flair reads the principal's status on every `tools/call` for a known tool, and
|
|
393
|
+
refuses those calls for a deactivated principal, including calls that carry a
|
|
394
|
+
token issued before the change:
|
|
395
|
+
|
|
396
|
+
```json
|
|
397
|
+
{"jsonrpc":"2.0","id":1,"error":{"code":-32001,"message":"forbidden: principal 'alice' is deactivated, so this token can no longer call tools. An operator must reactivate the principal (set its status to \"active\") to restore access."}}
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
- The same status refuses the principal's Ed25519-signed requests with HTTP
|
|
401
|
+
401 `{"error":"principal_deactivated"}`.
|
|
402
|
+
- Disabling does not revoke OAuth tokens: they stay valid until they expire,
|
|
403
|
+
and their tool calls are refused. Setting the status back to `active`
|
|
404
|
+
restores access for tokens that are still valid. `flair principal enable`
|
|
405
|
+
sets the status to `active`.
|
|
406
|
+
|
|
407
|
+
To close `/mcp` for everyone, unset `FLAIR_MCP_OAUTH` in the instance's
|
|
408
|
+
environment (or set it to `0`) and restart the instance; `flair mcp disable`
|
|
409
|
+
asks you to confirm the variable is unset, then sends the restart through the
|
|
410
|
+
instance's operations API.
|
|
411
|
+
|
|
412
|
+
## Check who you are
|
|
413
|
+
|
|
414
|
+
Call the `bootstrap` tool. Its structured result carries `agentId`, the
|
|
415
|
+
principal Flair resolved you to, and `scope`:
|
|
416
|
+
|
|
417
|
+
```json
|
|
418
|
+
"agentId": "alice",
|
|
419
|
+
"scope": { "agentId": "alice", "isAdmin": false, "reads": "own-and-org-non-private" }
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
If `agentId` is not the principal you expected, your login maps to a different
|
|
423
|
+
one (for example, one that just-in-time provisioning created); map it with
|
|
424
|
+
`flair mcp enable`. The stdio adapter's `bootstrap` returns text instead; an
|
|
425
|
+
agent can run `flair bootstrap --agent <id> --json` and read the same two
|
|
426
|
+
fields.
|
|
427
|
+
|
|
428
|
+
## Worked examples
|
|
429
|
+
|
|
430
|
+
The examples use placeholders: the instance `https://flair.example.com`, the
|
|
431
|
+
GitHub logins `alice`, `carol` and `dave`, the bot `bob-the-bot`, and another
|
|
432
|
+
MCP server at `https://mcp.acme.example`. `$TARGET_ADMIN_PASS` holds the
|
|
433
|
+
instance's admin password.
|
|
434
|
+
|
|
435
|
+
### People
|
|
436
|
+
|
|
437
|
+
#### 1. One person, one app: alice connects Claude
|
|
438
|
+
|
|
439
|
+
**Goal:** alice uses Claude with her hosted Flair, signs in with GitHub login
|
|
440
|
+
`alice`, and acts as principal `alice`.
|
|
441
|
+
|
|
442
|
+
Create a GitHub OAuth app whose callback URL is
|
|
443
|
+
`https://flair.example.com/oauth/github/callback` (the command prints this URL
|
|
444
|
+
too). The command stages `OAUTH_GITHUB_CLIENT_ID`, `OAUTH_GITHUB_CLIENT_SECRET`
|
|
445
|
+
and `OAUTH_GITHUB_REDIRECT_URI=<public-origin>/oauth` using `--issuer`
|
|
446
|
+
(default: `--instance`). Then run:
|
|
447
|
+
|
|
448
|
+
```bash
|
|
449
|
+
flair mcp enable \
|
|
450
|
+
--instance https://flair.example.com \
|
|
451
|
+
--idp-subject alice \
|
|
452
|
+
--principal alice \
|
|
453
|
+
--admin-pass "$TARGET_ADMIN_PASS"
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
When it finishes, it prints each step it ran, marked ✓ or ✗. The steps that
|
|
457
|
+
act:
|
|
458
|
+
|
|
459
|
+
- `idp-credentials` checks that the OAuth app's client id and secret are
|
|
460
|
+
present; in a terminal, the command prompts for them before the steps run.
|
|
461
|
+
- `secrets-provisioning` always stages the secrets the instance needs in a local
|
|
462
|
+
`0600` file. Without `--secrets-mechanism`, when the instance reports that it
|
|
463
|
+
supports Harper's env-secrets, the step also attempts to push each secret, then
|
|
464
|
+
reads back the stored row's `name` and `processEnv` flag (not the value). If
|
|
465
|
+
a push fails, or its row cannot be read back or does not show `processEnv` as
|
|
466
|
+
true, the step names the variables that failed and gives the staged-file
|
|
467
|
+
instructions instead.
|
|
468
|
+
- `identity-mapping` writes the credential for `alice` and reads the login's
|
|
469
|
+
credentials back (see [One mapping per login](#one-mapping-per-login)). The
|
|
470
|
+
command then asks you to confirm that the secrets are applied to the instance
|
|
471
|
+
(or takes `--confirm-secrets-applied`).
|
|
472
|
+
- `local-config-update` takes the first `config.yaml` it finds, in the current
|
|
473
|
+
directory and then in `~/.flair/`, on the machine you run it on, and sets
|
|
474
|
+
`mcp.enabled` to `${FLAIR_MCP_OAUTH}` when that file has the
|
|
475
|
+
`'@harperfast/oauth'` → `mcp` block. When there is no such file or block, or
|
|
476
|
+
the write fails, the step is marked failed and the command continues.
|
|
477
|
+
- `restart` sends a restart through the instance's operations API,
|
|
478
|
+
`verify-restart` waits up to 30 seconds for a new process ID, and
|
|
479
|
+
`self-verify` checks the published metadata; any of the three can fail the
|
|
480
|
+
run.
|
|
481
|
+
|
|
482
|
+
On success it ends with:
|
|
483
|
+
|
|
484
|
+
```
|
|
485
|
+
✓ The OAuth metadata check passed. The /mcp route itself was not probed.
|
|
486
|
+
|
|
487
|
+
claude.ai → Settings → Connectors → Add custom connector
|
|
488
|
+
URL: https://flair.example.com/mcp
|
|
489
|
+
(no client ID to enter — Claude presents its own Client ID Metadata Document URL automatically)
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
On a `*.harperfabric.com` instance, the command checks the target's OAuth
|
|
493
|
+
metadata after confirmation. If that check passes, the command
|
|
494
|
+
reaches its `fabric-operator-deploy` step and checks whether the public `/mcp`
|
|
495
|
+
OAuth surface already passes self-verify. If it does, the command
|
|
496
|
+
finishes there and prints the same connector details. If it does not, the run
|
|
497
|
+
stops at that step with instructions: apply the staged secrets, which include
|
|
498
|
+
`FLAIR_MCP_OAUTH=true`, to the instance's environment (when this run already
|
|
499
|
+
pushed them to the instance, the step says so and only asks for the restart),
|
|
500
|
+
restart the instance, then run `flair mcp enable` again with the same options
|
|
501
|
+
plus `--confirm-secrets-applied`. That run checks again and finishes once
|
|
502
|
+
self-verify passes. If the public origin cannot be reached, the step lists
|
|
503
|
+
checks to run instead of the activation instructions. At any point,
|
|
504
|
+
`flair mcp status --instance https://flair.example.com` reports whether the
|
|
505
|
+
surface answers.
|
|
506
|
+
|
|
507
|
+
**Check:** in Claude, `bootstrap` returns `"agentId": "alice"` and
|
|
508
|
+
`"isAdmin": false` in `scope`.
|
|
509
|
+
**Revoke:** `flair principal disable alice` on the Flair host.
|
|
510
|
+
|
|
511
|
+
#### 2. The same person, a second app: shared or separate
|
|
512
|
+
|
|
513
|
+
**Goal:** alice also uses Claude Code on her laptop, and decides whether it
|
|
514
|
+
shares her connector's memories.
|
|
515
|
+
|
|
516
|
+
- **Through `/mcp`: shared, with no command.** Add
|
|
517
|
+
`https://flair.example.com/mcp` to Claude Code as a remote HTTP MCP server.
|
|
518
|
+
Claude Code's `client_id` is on `claude.ai`, which the shipped list allows. The
|
|
519
|
+
mapping is per login, not per app, so when alice signs in with GitHub login
|
|
520
|
+
`alice`, Claude Code acts as `alice`.
|
|
521
|
+
- **Through the stdio adapter: separate unless linked.** Register an agent for
|
|
522
|
+
the laptop (as in [example 4](#4-a-bot-on-another-host-signs-with-its-own-key),
|
|
523
|
+
say `alice-laptop`) and set `FLAIR_URL=https://flair.example.com` and
|
|
524
|
+
`FLAIR_AGENT_ID=alice-laptop` in the adapter's config. `alice-laptop` and
|
|
525
|
+
`alice` are then two principals: each writes its own memories and reads the
|
|
526
|
+
other's non-private ones, and, neither being an admin, neither reads the
|
|
527
|
+
other's `private` memories. To make them one, map the login to the laptop
|
|
528
|
+
agent:
|
|
529
|
+
|
|
530
|
+
```bash
|
|
531
|
+
flair mcp enable \
|
|
532
|
+
--instance https://flair.example.com \
|
|
533
|
+
--idp-subject alice --principal alice-laptop \
|
|
534
|
+
--secrets-mechanism env-file \
|
|
535
|
+
--admin-pass "$TARGET_ADMIN_PASS"
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
Answer `n` when asked whether the staged secrets are applied. When the
|
|
539
|
+
`identity-mapping` step shows ✓, its output says `re-pointed`. The
|
|
540
|
+
connector's `bootstrap` then shows which principal it resolves to; it should
|
|
541
|
+
be `"agentId": "alice-laptop"`. Memories already written as `alice` stay with
|
|
542
|
+
`alice`.
|
|
543
|
+
|
|
544
|
+
**How to choose:** use one principal when both apps should see the same private
|
|
545
|
+
memories. Keep two when you want to revoke or audit them separately.
|
|
546
|
+
|
|
547
|
+
**Check:** `bootstrap` in each app returns the `agentId` you chose.
|
|
548
|
+
**Revoke:** `flair principal disable` for the principal you want to stop.
|
|
549
|
+
|
|
550
|
+
#### 3. A small team, and someone leaves
|
|
551
|
+
|
|
552
|
+
**Goal:** alice, carol and dave each connect as their own principal. Later, dave
|
|
553
|
+
leaves.
|
|
554
|
+
|
|
555
|
+
Map alice as in example 1. Map each of the others on the running instance:
|
|
556
|
+
|
|
557
|
+
```bash
|
|
558
|
+
flair mcp enable \
|
|
559
|
+
--instance https://flair.example.com \
|
|
560
|
+
--idp-subject carol --principal carol \
|
|
561
|
+
--secrets-mechanism env-file \
|
|
562
|
+
--admin-pass "$TARGET_ADMIN_PASS"
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
Answer `n` when asked whether the staged secrets are applied; the
|
|
566
|
+
`identity-mapping` step has run by then (see
|
|
567
|
+
[Map a person to a principal](#map-a-person-to-a-principal)).
|
|
568
|
+
Repeat for `dave`. Each of them reads their own memories and the others'
|
|
569
|
+
non-private ones.
|
|
570
|
+
|
|
571
|
+
**Check:** `bootstrap` returns `"agentId": "carol"` for carol and
|
|
572
|
+
`"agentId": "dave"` for dave.
|
|
573
|
+
|
|
574
|
+
**Revoke:** when dave leaves, run `flair principal disable dave` on the Flair
|
|
575
|
+
host. His app may still hold an access token that passes the OAuth check until
|
|
576
|
+
it expires, but his next `tools/call` for a known tool gets:
|
|
577
|
+
|
|
578
|
+
```json
|
|
579
|
+
{"jsonrpc":"2.0","id":1,"error":{"code":-32001,"message":"forbidden: principal 'dave' is deactivated, so this token can no longer call tools. An operator must reactivate the principal (set its status to \"active\") to restore access."}}
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
His memories stay, and those that are not `private` stay readable by alice and
|
|
583
|
+
carol.
|
|
584
|
+
|
|
585
|
+
### Bots
|
|
586
|
+
|
|
587
|
+
#### 4. A bot on another host signs with its own key
|
|
588
|
+
|
|
589
|
+
**Goal:** `bob-the-bot` runs on its own server and uses Flair with an Ed25519
|
|
590
|
+
key, the default for agents.
|
|
591
|
+
|
|
592
|
+
Run this on the bot's host, so that the private key is created where it is used:
|
|
593
|
+
|
|
594
|
+
```bash
|
|
595
|
+
flair agent add bob-the-bot \
|
|
596
|
+
--target https://flair.example.com \
|
|
597
|
+
--admin-pass-file ./target-admin-pass
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
The password file must be mode `0600`. For an `https` target on port 443, the
|
|
601
|
+
command sends the Agent record to the operations API on port 9925 of the <!-- docs-freshness-allow: hosted operations API port, not the data port -->
|
|
602
|
+
same host; pass `--ops-target <url>` if yours is elsewhere. It writes a new key
|
|
603
|
+
to `~/.flair/keys/bob-the-bot.key` (mode `0600`), or reuses the key already
|
|
604
|
+
there, sends an `insert` for the Agent record, and prints, among other lines:
|
|
605
|
+
|
|
606
|
+
```
|
|
607
|
+
✅ Agent 'bob-the-bot' (bob-the-bot) registered (ops: <operations API URL>)
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
If a well-formed Agent record with that id already exists, the command stops
|
|
611
|
+
before it writes a key file or an insert. It exits with an error that names
|
|
612
|
+
the id and tells you to run `flair agent rotate-key <id>` on the Flair host
|
|
613
|
+
(that command talks only to the local operations API and writes the
|
|
614
|
+
replacement private key on that host). An unreadable row, including one whose
|
|
615
|
+
`name` is missing or not a string, exits with "could not read" and does not
|
|
616
|
+
name that remedy. For a well-formed row the other remedy is
|
|
617
|
+
`flair agent remove <id>` and then `flair agent add` again.
|
|
618
|
+
`flair agent remove` tries to delete that agent's Memory and Soul rows as
|
|
619
|
+
well as the Agent row. An adapter on another machine still loads the previous
|
|
620
|
+
key until the new private key file is on that signing host. `FLAIR_KEY_PATH`
|
|
621
|
+
only names a path on the host where the adapter runs. Point it at that
|
|
622
|
+
local file when the key is not in the default location, then restart the
|
|
623
|
+
adapter. A new id is inserted, then
|
|
624
|
+
read back. The command prints the line above, and the public key on the
|
|
625
|
+
following line, only when the stored public key matches the key generated or
|
|
626
|
+
reused by this command. A skipped insert, a different stored key, or a row
|
|
627
|
+
with no usable public key is an error. A row that exists without a usable
|
|
628
|
+
public key is not reported as a missing row. Requests signed with a key that
|
|
629
|
+
does not match the stored one still get `invalid_signature` (below).
|
|
630
|
+
|
|
631
|
+
Configure the stdio adapter (`@tpsdev-ai/flair-mcp`) on the bot's host with
|
|
632
|
+
`FLAIR_URL=https://flair.example.com` and `FLAIR_AGENT_ID=bob-the-bot`. With
|
|
633
|
+
`FLAIR_KEY_PATH` and `FLAIR_KEY_DIR` unset, it looks for the key at
|
|
634
|
+
`~/.flair/keys/bob-the-bot.key` and, when it finds it, signs each request it
|
|
635
|
+
sends to Flair with it:
|
|
636
|
+
|
|
637
|
+
```
|
|
638
|
+
Authorization: TPS-Ed25519 bob-the-bot:<unix-ms>:<nonce>:<base64 signature>
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
The signature is Ed25519 over `bob-the-bot:<unix-ms>:<nonce>:<METHOD>:<path>`,
|
|
642
|
+
where the path includes any query string. By default the timestamp must be
|
|
643
|
+
within 30 seconds of the server's clock, and a nonce is accepted once. A request
|
|
644
|
+
refused by these checks gets HTTP 401:
|
|
645
|
+
|
|
646
|
+
| Situation | Body |
|
|
647
|
+
|---|---|
|
|
648
|
+
| No Agent record with that id | `{"error":"unknown_agent"}` |
|
|
649
|
+
| Registered id, signed with a key that is not its registered key | `{"error":"invalid_signature"}` |
|
|
650
|
+
| Principal deactivated | `{"error":"principal_deactivated"}` |
|
|
651
|
+
| Timestamp outside the window | `{"error":"timestamp_out_of_window"}` |
|
|
652
|
+
|
|
653
|
+
**Check:** `flair bootstrap --agent bob-the-bot --url https://flair.example.com --json`
|
|
654
|
+
and read `agentId` and `scope`.
|
|
655
|
+
**Revoke:** `flair principal disable bob-the-bot` on the Flair host; its next
|
|
656
|
+
request gets `{"error":"principal_deactivated"}`.
|
|
657
|
+
|
|
658
|
+
`flair agent remove bob-the-bot`, also run on the Flair host, asks you to type
|
|
659
|
+
`yes` (or takes `--force`), then:
|
|
660
|
+
|
|
661
|
+
- searches the agent's `Memory` and `Soul` rows and sends a delete for each one
|
|
662
|
+
it finds, without checking whether each delete succeeded;
|
|
663
|
+
- sends a delete for the `Agent` record, and stops with an error if the
|
|
664
|
+
operations API rejects it;
|
|
665
|
+
- unless you pass `--keep-keys`, attempts to delete the agent's key files
|
|
666
|
+
(private, public and `.bak`) from the keys directory on the machine it runs
|
|
667
|
+
on, ignoring any failure;
|
|
668
|
+
- prints `Key files deleted.` (with `--keep-keys`,
|
|
669
|
+
`Key files preserved (--keep-keys).`) and then
|
|
670
|
+
`✅ Agent 'bob-the-bot' removed successfully`, without checking the Memory,
|
|
671
|
+
Soul and key-file deletions.
|
|
672
|
+
|
|
673
|
+
Rows the agent owns in other tables, such as its workspace state, are left in
|
|
674
|
+
place.
|
|
675
|
+
|
|
676
|
+
#### 5. A bot reaches another OAuth-protected MCP server as itself
|
|
677
|
+
|
|
678
|
+
**Goal:** `bob-the-bot` calls the MCP server at `https://mcp.acme.example`
|
|
679
|
+
without a person signing in, using its Flair key as its client credential
|
|
680
|
+
(`client_credentials` with `private_key_jwt`).
|
|
681
|
+
|
|
682
|
+
When `FLAIR_MCP_ISSUER` or `FLAIR_PUBLIC_URL` is set, Flair publishes a Client
|
|
683
|
+
ID Metadata Document at `/MCPClientMetadata/<agent-id>` for an agent whose record
|
|
684
|
+
holds an Ed25519 public key (64 hex characters, or base64 that decodes to 32
|
|
685
|
+
bytes). With `FLAIR_MCP_ISSUER=https://flair.example.com`, the document for
|
|
686
|
+
`bob-the-bot` is served at
|
|
687
|
+
`https://flair.example.com/MCPClientMetadata/bob-the-bot`:
|
|
688
|
+
|
|
689
|
+
```json
|
|
690
|
+
{
|
|
691
|
+
"client_id": "https://flair.example.com/MCPClientMetadata/bob-the-bot",
|
|
692
|
+
"client_name": "bob-the-bot",
|
|
693
|
+
"jwks": { "keys": [ { "kty": "OKP", "crv": "Ed25519", "x": "<public key>", "kid": "bob-the-bot" } ] },
|
|
694
|
+
"token_endpoint_auth_method": "private_key_jwt",
|
|
695
|
+
"grant_types": ["client_credentials"]
|
|
696
|
+
}
|
|
697
|
+
```
|
|
698
|
+
|
|
699
|
+
With neither variable set, the path answers HTTP 501 (`mcp_issuer_not_configured`).
|
|
700
|
+
For an unknown agent, or one with no public key, it answers HTTP 404
|
|
701
|
+
(`agent_not_found_or_no_key`). For a record whose public key does not decode to
|
|
702
|
+
32 bytes, it answers HTTP 500 (`invalid_agent_key`).
|
|
703
|
+
|
|
704
|
+
The other server's authorization server must allow this. If it runs
|
|
705
|
+
`@harperfast/oauth` 2.5.0, that includes `mcp.clientCredentials.enabled: true`
|
|
706
|
+
and `flair.example.com` in its `clientIdMetadataDocuments.allowedHosts`.
|
|
707
|
+
|
|
708
|
+
On the bot's host, mint a token:
|
|
709
|
+
|
|
710
|
+
```bash
|
|
711
|
+
flair mcp token --agent-id bob-the-bot \
|
|
712
|
+
--client-id https://flair.example.com/MCPClientMetadata/bob-the-bot \
|
|
713
|
+
--token-endpoint https://mcp.acme.example/oauth/mcp/token \
|
|
714
|
+
--resource https://mcp.acme.example/mcp
|
|
715
|
+
```
|
|
716
|
+
|
|
717
|
+
It signs an EdDSA assertion with `iss` and `sub` set to the `client_id`, `aud`
|
|
718
|
+
set to the token endpoint, and a lifetime of at most 60 seconds, then sends the
|
|
719
|
+
token request. On success it prints
|
|
720
|
+
`access_token minted (<token type>, expires_in=<seconds>s):` followed by the
|
|
721
|
+
token, which the bot sends as `Authorization: Bearer <token>` to
|
|
722
|
+
`https://mcp.acme.example/mcp`. A `@harperfast/oauth` 2.5.0 server issues these
|
|
723
|
+
tokens for 300 seconds by default and no refresh token; mint another when it
|
|
724
|
+
expires.
|
|
725
|
+
|
|
726
|
+
Flair's own authorization server does not issue these tokens with the shipped
|
|
727
|
+
`config.yaml`, which has no `clientCredentials` block: it answers
|
|
728
|
+
`unsupported_grant_type`. This path is for reaching other servers.
|
|
729
|
+
|
|
730
|
+
**Check:** add `--dry-run` to sign the assertion and print its claims without
|
|
731
|
+
sending it, and fetch the metadata URL to see the published key.
|
|
732
|
+
**Revoke:** the other server's operator can remove `flair.example.com` from its
|
|
733
|
+
list. On Flair, the document remains served for a deactivated agent whose record
|
|
734
|
+
holds a valid Ed25519 public key, so `flair principal disable` does not withdraw
|
|
735
|
+
it. When `flair agent remove bob-the-bot` deletes the `Agent` record, the path
|
|
736
|
+
answers 404. An authorization server that fetched the document earlier can keep
|
|
737
|
+
using its cached copy until that copy expires.
|
|
738
|
+
|
|
739
|
+
#### 6. A bot and a person using the same app
|
|
740
|
+
|
|
741
|
+
**Goal:** alice runs Claude Code herself, and a nightly job runs Claude Code on a
|
|
742
|
+
build server. The job gets its own principal.
|
|
743
|
+
|
|
744
|
+
Register the job's agent as in example 4 and set
|
|
745
|
+
`FLAIR_URL=https://flair.example.com` and `FLAIR_AGENT_ID=bob-the-bot` in the
|
|
746
|
+
build server's MCP config. Do not copy alice's key to the server or set
|
|
747
|
+
`FLAIR_AGENT_ID=alice` there.
|
|
748
|
+
|
|
749
|
+
Why a separate principal:
|
|
750
|
+
|
|
751
|
+
- **Attribution.** The job's writes carry `bob-the-bot`. As a non-admin agent,
|
|
752
|
+
it cannot write a memory owned by `alice`.
|
|
753
|
+
- **Privacy.** alice's `private` memories are not returned to `bob-the-bot`, and
|
|
754
|
+
the bot's `private` memories are not returned to alice (neither is an admin).
|
|
755
|
+
Non-private memories are readable by both. A `memory_store` without a
|
|
756
|
+
`visibility` and with the default `standard` durability is `private`.
|
|
757
|
+
- **Revocation.** `flair principal disable bob-the-bot` gets the job's requests
|
|
758
|
+
refused and leaves alice working. A job that runs as `alice` cannot be cut
|
|
759
|
+
off without cutting off alice too.
|
|
760
|
+
|
|
761
|
+
What the bot reads follows [What they can touch](#3-what-they-can-touch): its
|
|
762
|
+
own memories and other agents' non-private ones. `flair grant` does not narrow
|
|
763
|
+
that, because reads do not consult memory grants.
|
|
764
|
+
|
|
765
|
+
**Check:** `flair bootstrap --agent bob-the-bot --url https://flair.example.com --json`
|
|
766
|
+
on the build server returns `"agentId": "bob-the-bot"` and `"isAdmin": false`
|
|
767
|
+
in `scope`.
|
|
768
|
+
**Revoke:** `flair principal disable bob-the-bot` on the Flair host.
|