RuleStack

Configs

Stacks

Compare

Diff

RuleStack

Configs

Stacks

Compare

Diff

Read API

RuleStack

Configs

Stacks

Compare

Diff

Read API

Configs/AGENTS.md/code-yeongyu/oh-my-openagent

AGENTS.md

packages/omo-opencode/src/features/skill-mcp-manager/AGENTS.md
AGENTS.md

Quality

70/100

Scores the file, not the repository.

Length

546 words

13 headings · 5 code blocks

Repository

67k

— · pushed 0 days ago

Last changed

2 days ago

First indexed 2 days ago.
code-yeongyu/oh-my-openagent/packages/omo-opencode/src/features/skill-mcp-manager/AGENTS.mdRawGitHub
1# src/features/skill-mcp-manager/ — Skill-Embedded MCP Client Lifecycle
2 
3**Generated:** 2026-05-15
4 
5## OVERVIEW
6 
7This module manages **tier 3** of the MCP system: skill-embedded MCP servers declared in SKILL.md YAML frontmatter. Per-session client isolation, dual transport (stdio + HTTP), OAuth 2.0 with step-up authentication, idle cleanup. Harness-neutral MCP client lifecycle and OAuth primitives are extracted to [`packages/mcp-client-core/`](../../../../../packages/mcp-client-core); this directory keeps the OpenCode manager wiring stable.
8 
9## THREE-TIER MCP CONTEXT
10 
11| Tier | Manager | Scope |
12|------|---------|-------|
13| 1. Built-in | `createBuiltinMcps()` (src/mcp/) | Global, 3 remote HTTP + 1 local stdio (`lsp`) |
14| 2. Claude Code | `claude-code-mcp-loader` (src/features/) | From `.mcp.json` |
15| 3. **Skill-embedded** | **`SkillMcpManager` (this module)** | **Per-session, from SKILL.md YAML** |
16 
17## CLIENT KEY FORMAT
18 
19```
20${sessionID}:${skillName}:${serverName}
21```
22 
23Enables: per-session isolation, same skill usable in multiple sessions concurrently, multiple servers per skill.
24 
25## DUAL TRANSPORT
26 
27| Type | File | Backend |
28|------|------|---------|
29| **stdio** | `stdio-client.ts` | `StdioClientTransport` (local process) |
30| **http** | `http-client.ts` | `StreamableHTTPClientTransport` (remote) |
31 
32**Detection** (connection-type.ts): explicit `type` field → URL presence → command presence. Legacy `"sse"` mapped to http.
33 
34## STATE
35 
36```typescript
37interface SkillMcpManagerState {
38 clients: Map<clientKey, ManagedClient> // Active connections
39 pendingConnections: Map<clientKey, Promise<Client>> // Race prevention
40 disconnectedSessions: Map<sessionID, generation> // Stale connection detection
41 authProviders: Map<url, OAuthProvider> // OAuth state per server
42 inFlightConnections: Map<sessionID, count> // Connection counting
43}
44```
45 
46## KEY FILES
47 
48| File | Purpose |
49|------|---------|
50| `manager.ts` | `SkillMcpManager` class — main API (getOrCreateClient, disconnectSession, listTools, callTool, etc.) |
51| `types.ts` | `ManagedStdioClient`, `ManagedHttpClient`, `SkillMcpManagerState`, `ConnectionType` |
52| `connection.ts` | Client factory with race prevention, retry, env var expansion |
53| `connection-type.ts` | Detect stdio vs http from config (legacy sse → http) |
54| `stdio-client.ts` | Stdio transport factory |
55| `http-client.ts` | HTTP transport factory |
56| `cleanup.ts` | SIGINT/SIGTERM handlers, idle timer (60s interval, 5min TTL) |
57| `oauth-handler.ts` | OAuth token management, refresh, step-up (403 scope escalation) |
58| `env-cleaner.ts` | Filter npm/pnpm/yarn config + 25+ secret patterns (_KEY, _SECRET, _TOKEN) |
59| `error-redaction.ts` | Redact sensitive data from error messages before logging |
60 
61## LIFECYCLE INTEGRATION
62 
63**Hook**: `src/plugin/event.ts` on `session.deleted`:
64```typescript
65await managers.skillMcpManager.disconnectSession(sessionInfo.id)
66```
67 
68## LIFECYCLE FLOW
69 
70```
711. session.created → No action (lazy connection)
722. First MCP tool call → getOrCreateClient() creates + caches
733. Ongoing use → lastUsedAt timestamp updated
744. Idle >5min → cleanup timer removes
755. session.deleted → disconnectSession() closes session clients
766. Process exit → disconnectAll() via SIGINT/SIGTERM handlers
77```
78 
79## RACE CONDITION PREVENTION
80 
81- **pendingConnections**: Deduplicates concurrent connection attempts for same key
82- **inFlightConnections**: Per-session counter, prevents premature cleanup during connection setup
83- **shutdownGeneration**: Counter-based stale connection detection after disconnect
84 
85## PUBLIC API
86 
87```typescript
88class SkillMcpManager {
89 constructor(options?: { createOAuthProvider? })
90 getOrCreateClient(info, config): Promise<Client>
91 disconnectSession(sessionID): Promise<void>
92 disconnectAll(): Promise<void>
93 listTools/Resources/Prompts(info, context): Promise<...[]>
94 callTool(info, context, name, args): Promise<unknown>
95 readResource(info, context, uri): Promise<unknown>
96 getPrompt(info, context, name, args): Promise<unknown>
97 getConnectedServers(): string[]
98 isConnected(info): boolean
99}
100```
101 
102## RETRY SEMANTICS
103 
104- `getOrCreateClientWithRetry()` — 3 attempts with force reconnect on failure
105- `withOperationRetry()` — OAuth-aware wrapper: step-up on 403, token refresh on 401
106 
107## SECURITY
108 
109- **env-cleaner.ts** — strips npm/pnpm config vars (prevents pnpm project isolation issues) and secret patterns before stdio spawn
110- **error-redaction.ts** — masks tokens/secrets in error messages before logger.log
111- **OAuth isolation** — auth providers keyed by server URL, tokens never cross servers
112 

Sections

  • src/features/skill-mcp-manager/ — Skill-Embedded MCP Client Lifecycle
  • OVERVIEW
  • THREE-TIER MCP CONTEXT
  • CLIENT KEY FORMAT
  • DUAL TRANSPORT
  • STATE
  • KEY FILES
  • LIFECYCLE INTEGRATION
  • LIFECYCLE FLOW
  • RACE CONDITION PREVENTION
  • PUBLIC API
  • RETRY SEMANTICS
  • SECURITY

What it covers

lint-formatarchitecturesecurityapi

Stack — with the evidence

typescript

(1.00)

bun

(1.00)

node

(0.70)

vitest

(0.70)

biome

(0.70)

javascript

(0.60)

github-actions

(0.60)

Format

AGENTS.md

A plain-markdown README for coding agents, deliberately unopinionated: no frontmatter, no globs, no vendor keys. That minimalism is why it became the one file a dozen different agents will read, and why it carries the least per-file targeting power of any format here.

What the corpus says about it

Repository

Owner
code-yeongyu
Language
—
License
—
Archived
no

All configs in this repo

Also in code-yeongyu/oh-my-openagent

Diff this repo’s formats

One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?

The other instruction files in this repository
RepositoryFormatStackCoversScoreChanged
code-yeongyu/oh-my-openagentpackages/omo-opencode/src/features/claude-code-agent-loader/AGENTS.md · 67kAGENTS.mdtypescriptbun+5archdeploymentagent-behaviour62/1002 days ago
code-yeongyu/oh-my-openagentpackages/omo-opencode/src/features/claude-code-mcp-loader/AGENTS.md · 67kAGENTS.mdtypescriptbun+5lint-formatarchsecuritydeployment+166/1002 days ago
code-yeongyu/oh-my-openagentpackages/omo-opencode/src/tools/background-task/AGENTS.md · 67kAGENTS.mdtypescriptbun+5arch70/1002 days ago
code-yeongyu/oh-my-openagentscript/AGENTS.md · 67kAGENTS.mdtypescriptbun+5buildtestarchdeployment80/1002 days ago
code-yeongyu/oh-my-openagentpackages/omo-opencode/src/features/claude-code-plugin-loader/AGENTS.md · 67kAGENTS.mdtypescriptbun+5archdeploymentagent-behaviour70/1002 days ago
code-yeongyu/oh-my-openagent.agents/AGENTS.md · 67kAGENTS.mdtypescriptbun+5stylearchtesting-strategydatabase64/1002 days ago
code-yeongyu/oh-my-openagent.opencode/AGENTS.md · 67kAGENTS.mdtypescriptbun+5stylearchdo-not71/1002 days ago
code-yeongyu/oh-my-openagentAGENTS.md · 67kAGENTS.mdtypescriptbun+5setupbuildtestlint-format+1184/1002 days ago
code-yeongyu/oh-my-openagentassets/AGENTS.md · 67kAGENTS.mdtypescriptbun+5buildteststylearch88/1002 days ago
code-yeongyu/oh-my-openagentbin/AGENTS.md · 67kAGENTS.mdtypescriptbun+5teststylearch64/1002 days ago
code-yeongyu/oh-my-openagentpackages/AGENTS.md · 67kAGENTS.mdtypescriptnode+5buildtestlint-formatstyle+383/1002 days ago
code-yeongyu/oh-my-openagentpackages/agents-md-core/AGENTS.md · 67kAGENTS.mdtypescriptbun+5archdependenciesapi48/1002 days ago
code-yeongyu/oh-my-openagentpackages/boulder-state/AGENTS.md · 67kAGENTS.mdtypescriptbun+5archapi48/1002 days ago
code-yeongyu/oh-my-openagentpackages/claude-code-compat-core/AGENTS.md · 67kAGENTS.mdtypescriptbun+5archagent-behaviour56/1002 days ago
code-yeongyu/oh-my-openagentpackages/comment-checker-core/AGENTS.md · 67kAGENTS.mdtypescriptbun+5archdependenciesapi48/1002 days ago
code-yeongyu/oh-my-openagentpackages/delegate-core/AGENTS.md · 67kAGENTS.mdtypescriptbun+5stylearchdependenciesapi60/1002 days ago
code-yeongyu/oh-my-openagentpackages/git-bash-mcp/AGENTS.md · 67kAGENTS.mdtypescriptbun+5buildtestlint-formatarch+182/1002 days ago
code-yeongyu/oh-my-openagentpackages/hashline-core/AGENTS.md · 67kAGENTS.mdtypescriptbun+5archtypesdependenciesapi48/1002 days ago
code-yeongyu/oh-my-openagentpackages/lsp-core/AGENTS.md · 67kAGENTS.mdtypescriptbun+5archmonorepo43/1002 days ago
code-yeongyu/oh-my-openagentpackages/lsp-daemon/AGENTS.md · 67kAGENTS.mdtypescriptnode+5buildtestlint-formatarch+189/100today
Diff against packages/omo-opencode/src/features/claude-code-agent-loader/AGENTS.md Diff against packages/omo-opencode/src/features/claude-code-mcp-loader/AGENTS.md Diff against packages/omo-opencode/src/tools/background-task/AGENTS.md Diff against script/AGENTS.md Diff against packages/omo-opencode/src/features/claude-code-plugin-loader/AGENTS.md Diff against .agents/AGENTS.md Diff against .opencode/AGENTS.md Diff against AGENTS.md Diff against assets/AGENTS.md Diff against bin/AGENTS.md Diff against packages/AGENTS.md Diff against packages/agents-md-core/AGENTS.md Diff against packages/boulder-state/AGENTS.md Diff against packages/claude-code-compat-core/AGENTS.md Diff against packages/comment-checker-core/AGENTS.md Diff against packages/delegate-core/AGENTS.md Diff against packages/git-bash-mcp/AGENTS.md Diff against packages/hashline-core/AGENTS.md Diff against packages/lsp-core/AGENTS.md Diff against packages/lsp-daemon/AGENTS.md

Similar configs

Same format, overlapping stack, ranked by quality.

Same format, overlapping stack, ranked by quality
RepositoryFormatStackCoversScoreChanged
aaif-goose/gooseAGENTS.md · 52kAGENTS.mdrusttypescript+2setupbuildtestlint-format+6100/1003 days ago
TryGhost/Ghoste2e/AGENTS.md · 55kAGENTS.mdtypescriptjavascript+12setupteststylearch+2100/1003 days ago
duckduckgo/content-scope-scriptsspecial-pages/AGENTS.md · 70AGENTS.mdtypescriptjavascript+5buildteststylearch+3100/1003 days ago
n8n-io/n8npackages/@n8n/agents/AGENTS.md · 199kAGENTS.mdtypescriptlangchain+16buildteststylearch+3100/1003 days ago
mui/material-uiAGENTS.md · 99kAGENTS.mdtypescriptjavascript+13setupbuildtestlint-format+9100/1003 days ago
SkeneTechnologies/skene-cookbookAGENTS.md · 51AGENTS.mdpythoneslint+4setupbuildtestlint-format+7100/1002 days ago
trick77/agents-md-syncAGENTS.md · 2AGENTS.mdtypescriptnode+4setupbuildteststyle+5100/1003 days ago
code-yeongyu/oh-my-openagentpackages/web/AGENTS.md · 67kAGENTS.mdtypescriptbun+10setupbuildtestlint-format+6100/1002 days ago
RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack