sereinflow ยท diff
git:20260831.b8c0ddc to git:20260901.bef2ba1
102 added, 234 removed. Audit A to A.
---
name: sereinflow
- description: Connect to the SereinFlow MCP service, load its current operating guide and live capabilities, and diagnose transport, authentication, and session failures with evidence.
+ description: Connect to SereinFlow MCP, load its live routing guide, and operate only the requested capability.
---
# SereinFlow MCP
- Use the configured `sereinflow` MCP server as the only source of truth for
- SereinFlow projects, flows, runs, debugging, versions, SereinLang compilation,
- and library package workflows.
-
- ## MCP capability contract
+ Use the configured `sereinflow` MCP server as the source of truth for
+ SereinFlow projects, flows, runs, debugging, versions, SereinLang and library
+ packages. Treat the service as a remote black box; do not use local source,
+ databases, library directories or uploaded binaries to explain a server result.
- When the connection is authenticated, the SereinFlow MCP server declares and
- implements these protocol capabilities:
+ ## Required loading order
- - `tools`: discover with `tools/list` and invoke with `tools/call`.
- - `resources`: discover fixed resources with `resources/list`, URI templates
- with `resources/templates/list`, and content with `resources/read`.
- - `prompts`: discover workflow prompts with `prompts/list` and retrieve one
- with `prompts/get`.
+ At the start of a task:
- The server declares `resources.subscribe: false` and `listChanged: false` for
- resources, tools, and prompts. Do not wait for subscription updates or
- list-change notifications; discover the current catalog when needed. The
- plugin manifest's `Interactive` and `Write` values are UI metadata, not MCP
- protocol capability declarations.
+ 1. Complete a fresh MCP `initialize` handshake and read its `instructions`.
+ 2. Read `sereinflow://ai/guide` with `resources/read`. This is the server's
+ authoritative routing entry point. In this repository its backing source is
+ `D:/Project/dotnet/SereinFlow/src/SereinFlow.Api/mcp/sereinflow-ai-guide.md`;
+ consume it through MCP rather than replacing it with a client-local path.
+ 3. Follow the guide and read only the smallest capability module needed for the
+ request. A request spanning capabilities may read multiple modules in task
+ order.
+ 4. Discover current tool/resource/prompt schemas only as needed and follow the
+ returned schemas. Do not load every skill Resource for every task.
- The HTTP connection obtains its bearer token only from the
- `SEREINFLOW_MCP_API_KEY` environment variable. Never put an API key in the
- plugin, repository, task text, tool arguments, or client-local project files.
- If initialization cannot authenticate, report that the SereinFlow MCP API key
- is absent, invalid, expired, or revoked; do not treat it as a missing Skill or
- attempt to bypass server authentication.
+ The capability index URIs remain valid for a second-level route, but are not a
+ substitute for the focused module when the guide names one. Do not assume that
+ this plugin contains the detailed server Skills.
- `bearer_token_env_var` is read by the Codex host that owns the MCP client. A
- PowerShell `$env:SEREINFLOW_MCP_API_KEY` value proves only that the current
- PowerShell process has the variable; it does not update an already-running
- Codex desktop process. `shell_environment_policy` controls Shell subprocesses,
- and `mcp_servers.<id>.env_vars` is for stdio servers; neither is a replacement
- for the HTTP bearer-token setting. Use the Codex credential/environment
- injection supported by the host, then restart Codex or start a new task.
+ ## Authentication
- ## Connection lifecycle and diagnostics
+ The HTTP MCP connection receives its bearer token only from
+ `SEREINFLOW_MCP_API_KEY`, as declared by the plugin's MCP configuration.
+ Never put the key in this file, task text, tool arguments, logs, repository
+ files or client-local project files. Never create a second authentication
+ mechanism or send an API key to a SereinFlow tool.
- Treat connection health as four separate layers. Do not collapse a transport
- error from the Codex MCP client into a conclusion about the SereinFlow service:
+ The variable is read by the host process that owns the MCP client. A PowerShell
+ `$env:SEREINFLOW_MCP_API_KEY` value affects that shell only; it does not update
+ an already-running Codex process. Shell environment policy and stdio server
+ `env_vars` are not replacements for the HTTP bearer-token setting. Enter the
+ secret through the host's supported credential/environment injection, then
+ restart Codex or start a new task after creating, rotating or changing it.
- 1. **Transport**: can the configured host and route be reached?
- 2. **Authentication**: does the endpoint accept the bearer token?
- 3. **MCP session**: did `initialize` succeed, and are the returned session and
- protocol headers used on follow-up requests?
- 4. **Capabilities**: can the authenticated session read the guide and list the
- current tools, resources, resource templates, and prompts?
+ ## Connection constraints
- The normal connection sequence is:
+ - Use the configured endpoint and one fresh `initialize` session.
+ - For every request after initialization, preserve the returned
+ `MCP-Session-Id` and send the negotiated/current `MCP-Protocol-Version`.
+ Do not hardcode a version that differs from the server handshake. The
+ client should send this header even though the current service does not yet
+ enforce it on every follow-up request.
+ - A successful `initialize` proves session creation only. Read the guide and
+ make the required capability call before reporting the service as healthy.
+ - Resources, tools and prompts do not provide subscription or list-change
+ updates in the current server contract. Discover catalogs when needed.
+ - Do not retry a stale or partial session. Establish a fresh session and retry
+ a read-only request once when the server reports a missing session header, an
+ expired session or a protocol mismatch. Treat the protocol header as current
+ client behavior guidance rather than a server-enforced requirement on every
+ request.
- 1. Use the configured `sereinflow` MCP server. Do not send an API key in tool
- arguments or try to create a second authentication mechanism.
- 2. Complete one fresh `initialize` handshake and record only non-secret
- evidence: status, error body category, and whether `MCP-Session-Id` was
- returned. Do not print the bearer token, full authorization header, or any
- secret-bearing response fields.
- 3. For every request after `initialize`, preserve the returned
- `MCP-Session-Id` and send `MCP-Protocol-Version: 2025-03-26` (header names
- are case-insensitive). If a session is stale or the server reports a
- missing protocol/session header, create a fresh session and retry the
- read-only request once.
- 4. Read `initialize.instructions`, then `sereinflow://ai/guide`, and only the
- relevant capability resource. A successful `initialize` alone proves only
- that a session was created; it is not a full health check.
- 5. Verify the session with the current capability catalogs: `tools/list`,
- `resources/list`, `resources/templates/list`, and `prompts/list`. Record
- successful result counts when available. An empty catalog is meaningful only
- after a successful authenticated `initialize` and a successful catalog
- response.
+ ## Bounded diagnostics
- When the MCP client reports an ambiguous failure, or when a user asks whether
- the service is connected, perform a bounded direct HTTP comparison against the
- same configured endpoint if shell/network diagnostics are available. Label
- every observation as either `Codex MCP client` or `direct probe`; a successful
- PowerShell probe proves the service and key work for that PowerShell process,
- not that an already-running Codex process has loaded the same environment.
- Keep the API key in the process environment and report only presence/absence
- and status classes.
+ When the MCP client fails ambiguously or the user asks whether the service is
+ connected, compare it with a bounded direct probe against the same endpoint
+ when shell/network diagnostics are available. Label observations `Codex MCP
+ client` or `direct probe`; a shell result proves only that shell's credentials
+ and network path.
- For a direct probe, use the configured URL and this sequence:
+ For a direct probe, use this order and keep the key in the process environment:
- 1. `GET /mcp`: `405 Method Not Allowed` is expected and proves that the
- listener and route are reachable; it is not an MCP failure. MCP requests
- use `POST`.
- 2. Unauthenticated `POST initialize`: `401` with
- `WWW-Authenticate: Bearer` proves that the route is reachable and bearer
- authentication is enforced. Never use this result alone to claim the key is
- invalid.
- 3. Authenticated `POST initialize`: `200` plus a session ID proves that the
- endpoint accepted the key and created an MCP session. Capture the session ID
- internally, but do not expose it as a credential or log it in full.
- 4. Authenticated follow-up catalog requests with both the session ID and
- `MCP-Protocol-Version: 2025-03-26`: successful `200` responses prove that
- the session can use the MCP API. Read the guide resource as a final
- application-level check.
+ 1. `GET /mcp` returning `405` proves the route is reachable; MCP uses `POST`.
+ 2. Unauthenticated `POST initialize` returning `401` with
+ `WWW-Authenticate: Bearer` proves bearer authentication is enforced. It
+ does not by itself prove a configured key is invalid.
+ 3. Authenticated `POST initialize` returning `200` and a session ID proves
+ authentication and session creation. Keep the ID internal.
+ 4. Authenticated follow-up reads with the session ID and negotiated protocol
+ header, followed by reading the guide, verify MCP application access. The
+ client should still send the negotiated protocol header even though the
+ current service does not yet reject every follow-up request that omits it.
- The diagnostic initialize payload must be a valid MCP JSON-RPC request, for
- example:
+ The initialize body must be valid MCP JSON-RPC. Use the current protocol
+ version returned by the server, for example:
```json
{
"jsonrpc": "2.0",
"id": "diagnostic-initialize",
"method": "initialize",
"params": {
- "protocolVersion": "2025-03-26",
+ "protocolVersion": "2025-06-18",
"capabilities": {},
- "clientInfo": {
- "name": "codex-sereinflow-diagnostic",
- "version": "1.0"
- }
+ "clientInfo": { "name": "codex-sereinflow-diagnostic", "version": "1.0" }
}
}
```
- For direct HTTP diagnostics, send `Content-Type: application/json` and an
- appropriate `Accept` header. Send `Authorization: Bearer <value>` only from
- the process environment; never put the value in this file, command output,
- task text, or a tool argument. Use the response session header on all
- subsequent requests. Handle either JSON or event-stream response framing when
- the transport allows both.
-
- Apply these bounded retry rules:
-
- - Retry connection resets, timeouts, and `502`/`503`/`504` only a small,
- finite number of times with short backoff while the service may be starting.
- - Retry `initialize`, catalog reads, and resource reads safely. Do not blindly
- retry a mutating `tools/call`; retry it only when the server contract says
- the operation is idempotent and supplies an idempotency key.
- - After a failed initialization, do not reuse a partial or stale session. After
- a client restart or server restart, establish a new session before listing
- capabilities.
- - Do not make repeated probes indefinitely. Report the attempts and the last
- observed status when the bounded check still fails.
+ Send `Content-Type: application/json` and an appropriate `Accept` header. Do
+ not print authorization headers, API keys, session IDs or sensitive response
+ fields. Retry connection resets, timeouts and `502`/`503`/`504` only a small,
+ finite number of times with short backoff. Never blindly retry a mutating call;
+ only retry one when its contract is idempotent and supplies an idempotency key.
- Use these evidence-based conclusions:
+ Use these conclusions:
- - `POST initialize` returning `401` with `WWW-Authenticate: Bearer` means the
- listener and route are reachable, but the key is missing, invalid, expired,
- or revoked.
- - Connection refused or a timeout means the configured host/port is not
- reachable from the process performing the probe, or the API is not running
- there.
- - `502` or `503` from a client transport is a gateway, connector, or startup
- failure. It is not proof that a local port has no listener; report the
- transport status separately.
- - If the direct probe reaches `GET /mcp` with `405`, gets `401` without a key,
- gets `200` with the configured key, and completes the follow-up catalog
- requests, the SereinFlow service and key are healthy. If the Codex MCP client
- still reports `502`, the likely fault is the Codex client/connector state or
- stale credential injection. Restart Codex or start a new task, then rerun the
- MCP handshake.
- - If the direct authenticated initialize returns `401`, distinguish an absent
- key from an invalid, expired, or revoked key without exposing the value. Do
- not replace it with a key in the repository, task text, or tool arguments.
- - If direct requests return `502`/`503`/`504`, the failure is in the service
- startup, gateway, or connector path. Do not state that authentication failed
- unless an authenticated request actually returned `401`.
- - If `initialize` succeeds but follow-up requests fail, suspect a missing or
- stale `MCP-Session-Id`, a missing `MCP-Protocol-Version`, an expired session,
- or a protocol mismatch before suspecting the API key. Establish one fresh
- session and retest a read-only catalog call.
- - If direct probing is unavailable, report the MCP client's exact observed
- status/error and mark service health as unverified. Do not claim the local
- service is down or the key is invalid based only on an unverified client
- error.
+ - Connection refused or timeout: the host/port is unreachable from the
+ probing process or the API is not listening there.
+ - Authenticated `401`: the key is absent, invalid, expired or revoked; do not
+ replace it with a repository or tool-argument key.
+ - `502`/`503`/`504`: gateway, connector or startup failure; do not call it an
+ authentication failure without an authenticated `401`.
+ - Initialize succeeds but a follow-up fails: suspect session ID, protocol
+ header, session expiry or protocol mismatch before suspecting the key.
+ - If direct probing is unavailable, report the exact client error and mark
+ service health unverified. Do not claim the local service is down.
- When reporting a connection test or failure, use this compact diagnostic
- record so the user can distinguish the failing layer:
+ Use this compact record for connection reports:
```text
Connection status: healthy | client-path-failed | auth-failed | unreachable | unknown
Endpoint: <configured endpoint, without credentials>
Transport: <status and evidence>
Authentication: <not tested | missing/invalid | accepted>
- Session/protocol: <not established | session established | follow-up headers verified>
- Capabilities: tools=<count or ?>, resources=<count or ?>,
- templates=<count or ?>, prompts=<count or ?>
+ Session/protocol: <not established | established | follow-up headers verified>
+ Capabilities: tools=<count or ?>, resources=<count or ?>, prompts=<count or ?>
Likely cause: <one evidence-based sentence>
Next action: <one concrete action>
```
- Never report "connected" after only seeing a client-side `200` or an
- `initialize` response. Report the layer that was verified and the layer that
- still failed. Preserve status codes and relevant safe response headers in the
- diagnostic notes, but redact authorization values, API keys, session IDs, and
- other secrets.
-
- After creating, rotating, or changing `SEREINFLOW_MCP_API_KEY`, restart the
- Codex process or start a new task so the MCP client reloads its credentials.
- The Web Console cannot mutate the environment of an already running Codex
- process. Once connected, repeat `initialize`, then discover `tools/list`,
- `resources/list`, `resources/templates/list`, and `prompts/list` before
- reporting actual server capabilities.
-
- ## Configure the client key
-
- The SereinFlow Web Console can generate and persist MCP keys. Open the
- environment settings, use the local-only first-key setup when no key exists,
- then create a project-scoped client key with the smallest required permissions.
- The complete `sfk_...` Secret is returned only once after creation or rotation.
-
- In the Codex MCP credential configuration, set the variable named
- `SEREINFLOW_MCP_API_KEY` to that complete Secret. The variable name is already
- declared by this plugin; the plugin never contains the Secret value. A browser
- cannot change the environment of an already running Codex process, so the
- Secret must be entered through the client's supported credential UI or secure
- environment/secret injection mechanism. Use the server bootstrap setting only
- for first-time recovery when the Web Console is unavailable, and remove it
- after a dedicated client key has been created.
-
- At the beginning of a task:
-
- 1. Read `initialize.instructions` from the MCP server.
- 2. Read the `sereinflow://ai/guide` resource.
- 3. Read only the relevant capability Resource:
- `sereinflow://ai/skills/sereinflow`,
- `sereinflow://ai/skills/sereinlang`, or
- `sereinflow://ai/skills/sereinflow-library-package`.
- 4. Discover `tools/list`, `resources/list`, and `prompts/list` as needed.
- 5. Follow the current server-provided guide and the schemas returned by the
- server. Do not rely on copied local SereinFlow source, database paths,
- library directories, or hardcoded workflow rules.
-
- The server index is dynamic and only routes the request to the relevant
- capability Resource. Read only the selected capability Resource; do not load
- all SereinFlow, SereinLang, and library rules for every task. The corresponding
- MCP tools are the live implementation of those capabilities. Never assume
- that this plugin contains the server source code or a local copy of the
- detailed Skills.
-
- ## Task-level write authorization
-
- For an explicit request to create a project, edit a flow, or upload or import a
- library, treat the initial request as authorization for that named logical task
- and its dependent MCP calls. Use `read -> preview -> inspect -> apply ->
- reread`, but do not ask for a separate confirmation after every preview or
- between dependent writes. A single request that includes library import,
- project attachment, and flow editing uses one authorization for the whole chain.
-
- The apply tools still require `confirmation: "APPLY"`, the preview fingerprint,
- and an idempotency key; fill those protocol fields without prompting again once
- the preview matches the user's requested scope.
-
- Pause for one concise confirmation only when the request is ambiguous, the
- preview reveals destructive or unexpected scope, the operation publishes or
- rolls back production, changes permissions or secrets, encounters a version
- conflict, or would perform a materially different operation. A preview is not
- authorization for work outside the requested scope. Read-only inspection,
- compilation, package scanning, and post-apply rereads do not require a prompt.
-
- ## Library family and upgrade workflow
+ Do not report "connected" after only a client-side `200` or `initialize`.
+ Report which layer was verified and redact secrets, full scripts, sensitive
+ literals and server-local absolute paths.
- For library-family assignment or a project library version upgrade, read the
- `sereinflow://ai/skills/sereinflow-library-package` capability Resource and
- discover the current tool schemas. A family assignment is administrator-only
- and uses its own preview/apply pair. It changes catalog membership only; it
- never changes the immutable ZIP or an existing flow binding.
+ ## Mutation gate
- For upgrades, follow this stateful sequence:
+ For an explicit request to create a project, edit a flow, publish, attach or
+ import a library, use one task-level authorization and this sequence:
```text
- read project library references
- -> read visible family/artifact candidates
- -> preview library upgrade
- -> inspect blockers and acknowledgements
- -> explicit user confirmation when the scoped request has not already authorized the apply
- -> apply with confirmation, fingerprint, and idempotency key
- -> reread persisted upgrade plan, project references, and flow
+ read current state -> preview requested scope -> inspect diagnostics/diff
+ -> apply the matching preview with confirmation: "APPLY", fingerprint and idempotency key
+ -> reread affected resources and verify persisted state
```
- The source artifact must be referenced by the project; the source and target
- must be assigned to the same family; the target must be available. Project
- scoped callers can read only their project's referenced family artifacts. The
- apply contract is bound to the stored preview and does not permit replacing its
- project, source artifact, target artifact, or upgrade plan. Batch applies are
- per-flow transactional and may return both successful and failed entries; use
- the persisted readback before presenting a completed result.
+ Do not ask for duplicate confirmation between dependent calls. Pause once when
+ the request is ambiguous, the preview is destructive or unexpected, production
+ state, permissions or secrets change, a version conflict occurs, or the scope
+ materially differs from the request. Read-only inspection, compilation and
+ post-apply rereads do not need confirmation.