{"id":"043c0964-93aa-4daf-b624-0d1bef865293","shortId":"RQ5JL9","kind":"skill","title":"agent-specific-mcp-server-initialization","tagline":"Connect each agent’s frontmatter MCP servers safely and tear them down without leaking clients, while honoring plugin-only guards.","description":"# SKILL: Agent-Specific MCP Server Initialization\n**Domain:** mcp-initialization\n**Trigger:** Load this skill when an agent defines extra MCP servers in its frontmatter and those clients must be joined to the parent session.\n**Source Pattern:** Distilled from reviewed subagent orchestration, isolation, and lifecycle implementations.\n\n## Core Method\nIterate the servers declared by the child agent, resolve named references from shared MCP configuration, and treat inline declarations as new agent-owned connections. Merge the resulting clients and tools into the inherited parent context, but keep track of which connections were created specifically for that child agent. When the agent ends, tear down only those agent-owned connections while leaving inherited shared clients intact. If no extra servers are declared, return the parent context unchanged.\n\n## Key Rules\n- Short-circuit when the agent declares no extra MCP servers and return the inherited clients unchanged.\n- For string specs, reuse memoized MCP configs; for inline objects, mark the resulting clients as newly created so their cleanup runs after the agent ends.\n- Always return the merged client list plus the fetched tools, and expose a cleanup closure that only targets the newly created clients.\n- Guard the loop with logging for missing configs so failures degrade gracefully instead of throwing.\n\n## Example Application\nWhen implementing a custom agent that needs access to an inline MCP server, plug into this skill to merge the new server with the parent clients, reuse any shared configs, and ensure only the inline connection runs its cleanup path.\n\n## Anti-Patterns (What NOT to do)\n- Don’t rebuild the entire MCP client list from scratch every turn; reuse the inherited parent clients and append the new ones instead.\n- Don’t forget to clean up inline MCP servers; leaking them leaves dangling connections and stale credentials.","tags":["agent","specific","mcp","server","initialization","cskill","agents","ychampion","agent-skills","ai-agents","cli","coding-agents"],"capabilities":["skill","source-ychampion","skill-agent-specific-mcp-server-initialization","topic-agent-skills","topic-ai-agents","topic-cli","topic-coding-agents","topic-context-engineering","topic-developer-tools","topic-mcp","topic-multi-agent","topic-terminal-ui"],"categories":["cskill-agents"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/ychampion/cskill-agents/agent-specific-mcp-server-initialization","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add ychampion/cskill-agents","source_repo":"https://github.com/ychampion/cskill-agents","install_from":"skills.sh"}},"qualityScore":"0.467","qualityRationale":"deterministic score 0.47 from registry signals: · indexed on github topic:agent-skills · 34 github stars · SKILL.md body (1,911 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-04-22T06:56:44.457Z","embedding":null,"createdAt":"2026-04-18T22:19:40.621Z","updatedAt":"2026-04-22T06:56:44.457Z","lastSeenAt":"2026-04-22T06:56:44.457Z","tsv":"'access':244 'agent':2,9,30,45,83,98,124,127,134,161,196,241 'agent-own':97,133 'agent-specif':29 'agent-specific-mcp-server-initi':1 'alway':198 'anti':278 'anti-pattern':277 'append':302 'applic':236 'child':82,123 'circuit':158 'clean':311 'cleanup':192,211,275 'client':21,55,104,141,171,186,202,219,262,290,300 'closur':212 'config':179,227,266 'configur':90 'connect':7,100,117,136,272,320 'context':111,152 'core':74 'creat':119,189,218 'credenti':323 'custom':240 'dangl':319 'declar':79,94,148,162 'defin':46 'degrad':230 'distil':65 'domain':35 'end':128,197 'ensur':268 'entir':288 'everi':294 'exampl':235 'expos':209 'extra':47,145,164 'failur':229 'fetch':206 'forget':309 'frontmatt':11,52 'grace':231 'guard':27,220 'honor':23 'implement':73,238 'inherit':109,139,170,298 'initi':6,34,38 'inlin':93,181,247,271,313 'instead':232,306 'intact':142 'isol':70 'iter':76 'join':58 'keep':113 'key':154 'leak':20,316 'leav':138,318 'lifecycl':72 'list':203,291 'load':40 'log':224 'loop':222 'mark':183 'mcp':4,12,32,37,48,89,165,178,248,289,314 'mcp-initi':36 'memoiz':177 'merg':101,201,255 'method':75 'miss':226 'must':56 'name':85 'need':243 'new':96,257,304 'newli':188,217 'object':182 'one':305 'orchestr':69 'own':99,135 'parent':61,110,151,261,299 'path':276 'pattern':64,279 'plug':250 'plugin':25 'plugin-on':24 'plus':204 'rebuild':286 'refer':86 'resolv':84 'result':103,185 'return':149,168,199 'reus':176,263,296 'review':67 'rule':155 'run':193,273 'safe':14 'scratch':293 'server':5,13,33,49,78,146,166,249,258,315 'session':62 'share':88,140,265 'short':157 'short-circuit':156 'skill':28,42,253 'skill-agent-specific-mcp-server-initialization' 'sourc':63 'source-ychampion' 'spec':175 'specif':3,31,120 'stale':322 'string':174 'subag':68 'target':215 'tear':16,129 'throw':234 'tool':106,207 'topic-agent-skills' 'topic-ai-agents' 'topic-cli' 'topic-coding-agents' 'topic-context-engineering' 'topic-developer-tools' 'topic-mcp' 'topic-multi-agent' 'topic-terminal-ui' 'track':114 'treat':92 'trigger':39 'turn':295 'unchang':153,172 'without':19","prices":[{"id":"817f2a84-e70a-4653-80b3-4b9c4c0c7b5a","listingId":"043c0964-93aa-4daf-b624-0d1bef865293","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"ychampion","category":"cskill-agents","install_from":"skills.sh"},"createdAt":"2026-04-18T22:19:40.621Z"}],"sources":[{"listingId":"043c0964-93aa-4daf-b624-0d1bef865293","source":"github","sourceId":"ychampion/cskill-agents/agent-specific-mcp-server-initialization","sourceUrl":"https://github.com/ychampion/cskill-agents/tree/main/skills/agent-specific-mcp-server-initialization","isPrimary":false,"firstSeenAt":"2026-04-18T22:19:40.621Z","lastSeenAt":"2026-04-22T06:56:44.457Z"}],"details":{"listingId":"043c0964-93aa-4daf-b624-0d1bef865293","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"ychampion","slug":"agent-specific-mcp-server-initialization","github":{"repo":"ychampion/cskill-agents","stars":34,"topics":["agent-skills","ai-agents","cli","coding-agents","context-engineering","developer-tools","mcp","multi-agent","terminal-ui"],"license":"mit","html_url":"https://github.com/ychampion/cskill-agents","pushed_at":"2026-04-04T14:13:23Z","description":"Agent skills for coding CLIs, multi-agent runtimes, context engines, MCP extensions, and terminal tooling. Instead of using claude code's source code, give your agent skills to create your own!","skill_md_sha":"20de0872cb6601d484fae60115464a100d7a07f7","skill_md_path":"skills/agent-specific-mcp-server-initialization/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/ychampion/cskill-agents/tree/main/skills/agent-specific-mcp-server-initialization"},"layout":"multi","source":"github","category":"cskill-agents","frontmatter":{"name":"agent-specific-mcp-server-initialization","description":"Connect each agent’s frontmatter MCP servers safely and tear them down without leaking clients, while honoring plugin-only guards."},"skills_sh_url":"https://skills.sh/ychampion/cskill-agents/agent-specific-mcp-server-initialization"},"updatedAt":"2026-04-22T06:56:44.457Z"}}