[{"data":1,"prerenderedAt":978,"buildId":979},["ShallowReactive",2],{"docs:\u002Fguide\u002Fhooks-and-mcp":3},{"page":4,"section":16,"document":17,"credits":10,"prev":970,"next":974},{"id":5,"path":6,"file":7,"title":8,"sourceTitle":8,"description":9,"tagline":9,"eyebrow":10,"credits":10,"keywords":11,"icon":12,"layout":13,"sidebar":14,"toc":14,"kind":10,"group":10,"navigation":14,"order":15},"hooks-and-mcp","\u002Fguide\u002Fhooks-and-mcp","guide\u002Fhooks-and-mcp.md","Hooks and MCP servers","Start syncs from agent sessions, sync MCP servers and agent hook files into each agent, and run your own commands after a sync.",null,[],"i-lucide-plug","article",true,5,"guide",{"nodes":18,"toc":960},[19,23,100,107,117,170,219,241,255,265,288,309,321,329,334,339,489,541,583,621,632,635,649,652,657,664,683,764,794,800,806,865,914,929,935],[20,21,22],"p",{},"Three features have \"hook\" or \"MCP\" in their name. They do different jobs and are set up in different places.",[24,25,26,42],"table",{},[27,28,29],"thead",{},[30,31,32,36,39],"tr",{},[33,34,35],"th",{},"Feature",[33,37,38],{},"Set up with",[33,40,41],{},"What it does",[43,44,45,64,80],"tbody",{},[30,46,47,55,61],{},[48,49,50],"td",{},[51,52,54],"a",{"href":53},"#session-hooks","Session hooks",[48,56,57],{},[58,59,60],"code",{},"fleetrc hook install",[48,62,63],{},"Start a sync when a Claude Code or Codex session opens.",[30,65,66,72,77],{},[48,67,68],{},[51,69,71],{"href":70},"#mcp-servers","MCP servers",[48,73,74],{},[58,75,76],{},"sources[].mcp",[48,78,79],{},"Write MCP servers into each agent's config.",[30,81,82,88,97],{},[48,83,84],{},[51,85,87],{"href":86},"#hooks-in-the-manifest","Hooks in the manifest",[48,89,90,93,94],{},[58,91,92],{},"sources[].agentHooks"," and ",[58,95,96],{},"hooks",[48,98,99],{},"Sync hook files into agents, or run your commands after a sync.",[101,102,54],"h2",{"id":103,"anchor":104},"session-hooks",{"label":105,"icon":106},"Section titled \"Session hooks\"","#",[20,108,109,112,113,116],{},[58,110,111],{},"init"," adds a ",[58,114,115],{},"SessionStart"," hook to Claude Code and Codex. When a session opens, the hook starts a background sync. Nothing else in the manifest controls it.",[118,119,123],"pre",{"language":120,"frame":121,"class":122,"wrap":14},"sh","terminal","shiki shiki-themes github-light-default github-dark-default dark:github-dark-default",[58,124,126,146,147,146,161],{"class":125},"language-sh",[127,128,131,135,139,142],"span",{"class":129,"style":130},"line","display: inline",[127,132,134],{"style":133},"color:#953800;--shiki-dark:#FFA657","fleetrc",[127,136,138],{"style":137},"color:#0A3069;--shiki-dark:#A5D6FF"," hook",[127,140,141],{"style":137}," install",[127,143,145],{"style":144},"color:#6E7781;--shiki-dark:#8B949E","            # each agent whose folder exists","\n",[127,148,149,151,153,155,158],{"class":129,"style":130},[127,150,134],{"style":133},[127,152,138],{"style":137},[127,154,141],{"style":137},[127,156,157],{"style":137}," codex",[127,159,160],{"style":144},"      # one agent, creating its folder if needed",[127,162,163,165,167],{"class":129,"style":130},[127,164,134],{"style":133},[127,166,138],{"style":137},[127,168,169],{"style":137}," remove",[24,171,172,182],{},[27,173,174],{},[30,175,176,179],{},[33,177,178],{},"Agent",[33,180,181],{},"File",[43,183,184,204],{},[30,185,186,191],{},[48,187,188],{},[58,189,190],{},"claude-code",[48,192,193,196,197,200,201],{},[58,194,195],{},"settings.json"," in ",[58,198,199],{},"~\u002F.claude",", or in ",[58,202,203],{},"CLAUDE_CONFIG_DIR",[30,205,206,211],{},[48,207,208],{},[58,209,210],{},"codex",[48,212,213,196,216],{},[58,214,215],{},"hooks.json",[58,217,218],{},"~\u002F.codex",[20,220,221,222,93,225,228,229,232,233,236,237,240],{},"Both commands keep your other hooks and fields, take ",[58,223,224],{},"--dry-run",[58,226,227],{},"--json",", and exit ",[58,230,231],{},"1"," when a file does not parse. ",[58,234,235],{},"init --no-hooks"," skips the install, and so does ",[58,238,239],{},"fleet init --no-hooks"," on each host.",[20,242,243,244,247,248,250,251,254],{},"The hook runs ",[58,245,246],{},"fleetrc hook run \u003Cagent>",". It reads the event from stdin, ignores anything but ",[58,249,115],{},", and starts ",[58,252,253],{},"fleetrc sync"," in the background only when:",[256,257,258,262],"ul",{},[259,260,261],"li",{},"no sync was attempted in the last 15 minutes, and",[259,263,264],{},"no sync is running.",[20,266,267,268,271,272,275,276,279,280,283,284,287],{},"The 15 minutes count from the last attempt, not the last success, so a sync that fails offline waits for the next window. The hook makes no network call, prints nothing and always exits ",[58,269,270],{},"0",", so it never blocks a session. The sync it starts logs to ",[58,273,274],{},"fleetrc-sync.log"," in the state folder's ",[58,277,278],{},"logs"," directory and runs with the ",[58,281,282],{},"PATH"," saved when you ran ",[58,285,286],{},"hook install",", not the agent's.",[20,289,290,291,294,295,298,299,301,302,308],{},"fleetrc installs no prompt hook. An old ",[58,292,293],{},"UserPromptSubmit"," entry (",[58,296,297],{},"fleetrc hook prompt",") starts no sync. In Claude Code it only prints a line naming skills that arrived after the session began. ",[58,300,286],{}," replaces these entries with the session hook, and ",[51,303,305],{"href":304},"\u002Freference\u002Fdoctor",[58,306,307],{},"doctor"," warns about them.",[310,311,314],"github-callout",{"type":312,"title":313},"note","Note",[20,315,316,317,320],{},"Codex runs a new hook only after you approve it. Open ",[58,318,319],{},"\u002Fhooks"," in Codex once per machine and approve fleetrc's hook. Codex records approval with a hash of each hook, so fleetrc rewrites its own entry in place and leaves a no-op where it removes one that other hooks follow.",[20,322,323,324,328],{},"On a machine with no agent, such as a server, use the ",[51,325,327],{"href":326},"\u002Fguide\u002Ftimer","timer"," instead.",[101,330,71],{"id":331,"anchor":332},"mcp-servers",{"label":333,"icon":106},"Section titled \"MCP servers\"",[20,335,336,338],{},[58,337,76],{}," is the path of a file in the source, in Claude Code's format. fleetrc writes each server into every agent's own config and removes it when you drop it from the file.",[118,340,343],{"language":341,"filename":342,"class":122,"wrap":14},"json","mcp.json",[58,344,346,146,352,146,361,146,368,146,382,146,402,146,421,146,426,146,433,146,445,146,457,146,474,146,479,146,484],{"class":345},"language-json",[127,347,348],{"class":129,"style":130},[127,349,351],{"style":350},"color:#1F2328;--shiki-dark:#E6EDF3","{",[127,353,354,358],{"class":129,"style":130},[127,355,357],{"style":356},"color:#116329;--shiki-dark:#7EE787","  \"mcpServers\"",[127,359,360],{"style":350},": {",[127,362,363,366],{"class":129,"style":130},[127,364,365],{"style":356},"    \"docs\"",[127,367,360],{"style":350},[127,369,370,373,376,379],{"class":129,"style":130},[127,371,372],{"style":356},"      \"command\"",[127,374,375],{"style":350},": ",[127,377,378],{"style":137},"\"npx\"",[127,380,381],{"style":350},",",[127,383,384,387,390,393,396,399],{"class":129,"style":130},[127,385,386],{"style":356},"      \"args\"",[127,388,389],{"style":350},": [",[127,391,392],{"style":137},"\"-y\"",[127,394,395],{"style":350},", ",[127,397,398],{"style":137},"\"docs-mcp\"",[127,400,401],{"style":350},"],",[127,403,404,407,410,413,415,418],{"class":129,"style":130},[127,405,406],{"style":356},"      \"env\"",[127,408,409],{"style":350},": { ",[127,411,412],{"style":356},"\"DOCS_TOKEN\"",[127,414,375],{"style":350},[127,416,417],{"style":137},"\"${DOCS_TOKEN}\"",[127,419,420],{"style":350}," }",[127,422,423],{"class":129,"style":130},[127,424,425],{"style":350},"    },",[127,427,428,431],{"class":129,"style":130},[127,429,430],{"style":356},"    \"search\"",[127,432,360],{"style":350},[127,434,435,438,440,443],{"class":129,"style":130},[127,436,437],{"style":356},"      \"type\"",[127,439,375],{"style":350},[127,441,442],{"style":137},"\"http\"",[127,444,381],{"style":350},[127,446,447,450,452,455],{"class":129,"style":130},[127,448,449],{"style":356},"      \"url\"",[127,451,375],{"style":350},[127,453,454],{"style":137},"\"https:\u002F\u002Fmcp.example.com\"",[127,456,381],{"style":350},[127,458,459,462,464,467,469,472],{"class":129,"style":130},[127,460,461],{"style":356},"      \"headers\"",[127,463,409],{"style":350},[127,465,466],{"style":356},"\"Authorization\"",[127,468,375],{"style":350},[127,470,471],{"style":137},"\"Bearer ${SEARCH_TOKEN}\"",[127,473,420],{"style":350},[127,475,476],{"class":129,"style":130},[127,477,478],{"style":350},"    }",[127,480,481],{"class":129,"style":130},[127,482,483],{"style":350},"  }",[127,485,486],{"class":129,"style":130},[127,487,488],{"style":350},"}",[118,490,492],{"language":341,"filename":491,"class":122,"wrap":14},".fleetrc\u002Fmanifest.json",[58,493,494,146,498,146,537],{"class":345},[127,495,496],{"class":129,"style":130},[127,497,351],{"style":350},[127,499,500,503,506,509,511,514,516,519,521,524,526,529,531,534],{"class":129,"style":130},[127,501,502],{"style":356},"  \"sources\"",[127,504,505],{"style":350},": [{ ",[127,507,508],{"style":356},"\"id\"",[127,510,375],{"style":350},[127,512,513],{"style":137},"\"personal\"",[127,515,395],{"style":350},[127,517,518],{"style":356},"\"git\"",[127,520,375],{"style":350},[127,522,523],{"style":137},"\"me\u002Fagent-config\"",[127,525,395],{"style":350},[127,527,528],{"style":356},"\"mcp\"",[127,530,375],{"style":350},[127,532,533],{"style":137},"\"mcp.json\"",[127,535,536],{"style":350}," }]",[127,538,539],{"class":129,"style":130},[127,540,488],{"style":350},[20,542,543,544,395,547,395,550,395,553,556,557,395,560,395,563,566,567,570,571,574,575,578,579,582],{},"A server is local (",[58,545,546],{},"command",[58,548,549],{},"args",[58,551,552],{},"env",[58,554,555],{},"cwd",") or remote (",[58,558,559],{},"url",[58,561,562],{},"headers",[58,564,565],{},"type"," of ",[58,568,569],{},"http"," or ",[58,572,573],{},"sse","). Add ",[58,576,577],{},"\"agents\": [\"claude-code\", \"cursor\"]"," to send it to fewer agents. The manifest's ",[58,580,581],{},"agents"," decides which agents get servers at all, from Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Grok and OpenCode.",[20,584,585,586,589,590,593,594,597,598,601,602,604,605,395,608,395,611,395,614,570,617,620],{},"Write secrets as ",[58,587,588],{},"${VAR}"," and set ",[58,591,592],{},"VAR"," where each agent starts. fleetrc translates the reference into each agent's syntax, such as ",[58,595,596],{},"${env:VAR}"," for Cursor and ",[58,599,600],{},"{env:VAR}"," for OpenCode. A literal value in a header, or in an ",[58,603,552],{}," key that contains ",[58,606,607],{},"TOKEN",[58,609,610],{},"KEY",[58,612,613],{},"SECRET",[58,615,616],{},"PASSWORD",[58,618,619],{},"AUTH",", fails that server and syncs the others.",[20,622,623,624,627,628,631],{},"An agent that cannot take a server as written skips it with the reason. Codex reads a variable only as a whole value, so ",[58,625,626],{},"\"Authorization\": \"Bearer ${SEARCH_TOKEN}\""," works there and ",[58,629,630],{},"\"--token=${TOKEN}\""," does not.",[20,633,634],{},"If you edit a synced entry by hand, the next sync holds it as it is and says so. Compare it with the manifest's version:",[118,636,637],{"language":120,"frame":121,"class":122,"wrap":14},[58,638,639],{"class":125},[127,640,641,643,646],{"class":129,"style":130},[127,642,134],{"style":133},[127,644,645],{"style":137}," diff",[127,647,648],{"style":137}," mcp\u002Fclaude-code\u002Fdocs",[20,650,651],{},"Delete the held entry in the agent's config to take the manifest's. A server of the same name that fleetrc did not write is left alone and reported as foreign.",[101,653,87],{"id":654,"anchor":655},"hooks-in-the-manifest",{"label":656,"icon":106},"Section titled \"Hooks in the manifest\"",[658,659,663],"h3",{"id":660,"anchor":661},"agent-hook-files",{"label":662,"icon":106},"Section titled \"Agent hook files\"","Agent hook files",[20,665,666,668,669,395,671,395,673,395,676,570,679,682],{},[58,667,92],{}," syncs hook definitions into agents, in each agent's own format. A string path is a Claude Code file. An object gives a path per agent: ",[58,670,190],{},[58,672,210],{},[58,674,675],{},"grok",[58,677,678],{},"gemini-cli",[58,680,681],{},"cursor",".",[118,684,685],{"language":341,"filename":491,"class":122,"wrap":14},[58,686,687,146,691,146,697,146,702,146,713,146,724,146,751,146,755,146,760],{"class":345},[127,688,689],{"class":129,"style":130},[127,690,351],{"style":350},[127,692,693,695],{"class":129,"style":130},[127,694,502],{"style":356},[127,696,389],{"style":350},[127,698,699],{"class":129,"style":130},[127,700,701],{"style":350},"    {",[127,703,704,707,709,711],{"class":129,"style":130},[127,705,706],{"style":356},"      \"id\"",[127,708,375],{"style":350},[127,710,513],{"style":137},[127,712,381],{"style":350},[127,714,715,718,720,722],{"class":129,"style":130},[127,716,717],{"style":356},"      \"git\"",[127,719,375],{"style":350},[127,721,523],{"style":137},[127,723,381],{"style":350},[127,725,726,729,731,734,736,739,741,744,746,749],{"class":129,"style":130},[127,727,728],{"style":356},"      \"agentHooks\"",[127,730,409],{"style":350},[127,732,733],{"style":356},"\"claude-code\"",[127,735,375],{"style":350},[127,737,738],{"style":137},"\"hooks\u002Fclaude.json\"",[127,740,395],{"style":350},[127,742,743],{"style":356},"\"codex\"",[127,745,375],{"style":350},[127,747,748],{"style":137},"\"hooks\u002Fcodex.json\"",[127,750,420],{"style":350},[127,752,753],{"class":129,"style":130},[127,754,478],{"style":350},[127,756,757],{"class":129,"style":130},[127,758,759],{"style":350},"  ]",[127,761,762],{"class":129,"style":130},[127,763,488],{"style":350},[20,765,766,767,770,771,773,774,776,777,780,781,783,784,786,787,789,790,793],{},"fleetrc translates nothing here. Claude Code's hooks go into a plugin at ",[58,768,769],{},"~\u002F.claude\u002Fskills\u002Ffleetrc",", so a skill named ",[58,772,134],{}," is refused. Codex's go into ",[58,775,215],{},", Grok's into ",[58,778,779],{},"~\u002F.grok\u002Fhooks",", Gemini CLI's into ",[58,782,195],{}," and Cursor's into ",[58,785,215],{},", each beside your own. As with MCP, a hand-edited entry is held. In Codex, a new or changed group waits for approval in ",[58,788,319],{},", and sync says so with a ",[58,791,792],{},"review:"," line.",[658,795,799],{"id":796,"anchor":797},"commands-after-a-sync",{"label":798,"icon":106},"Section titled \"Commands after a sync\"","Commands after a sync",[20,801,802,803,805],{},"The root manifest's ",[58,804,96],{}," run shell commands after a sync that changed matching files.",[118,807,808],{"language":341,"filename":491,"class":122,"wrap":14},[58,809,810,146,814,146,821,146,857,146,861],{"class":345},[127,811,812],{"class":129,"style":130},[127,813,351],{"style":350},[127,815,816,819],{"class":129,"style":130},[127,817,818],{"style":356},"  \"hooks\"",[127,820,389],{"style":350},[127,822,823,826,829,831,834,836,839,841,844,846,849,851,854],{"class":129,"style":130},[127,824,825],{"style":350},"    { ",[127,827,828],{"style":356},"\"name\"",[127,830,375],{"style":350},[127,832,833],{"style":137},"\"pstack\"",[127,835,395],{"style":350},[127,837,838],{"style":356},"\"run\"",[127,840,375],{"style":350},[127,842,843],{"style":137},"\"node build.mjs\"",[127,845,395],{"style":350},[127,847,848],{"style":356},"\"on\"",[127,850,389],{"style":350},[127,852,853],{"style":137},"\"personal:pstack\u002F**\"",[127,855,856],{"style":350},"] }",[127,858,859],{"class":129,"style":130},[127,860,759],{"style":350},[127,862,863],{"class":129,"style":130},[127,864,488],{"style":350},[24,866,867,877],{},[27,868,869],{},[30,870,871,874],{},[33,872,873],{},"Field",[33,875,876],{},"Meaning",[43,878,879,889,901],{},[30,880,881,886],{},[48,882,883],{},[58,884,885],{},"run",[48,887,888],{},"The shell command. Required.",[30,890,891,896],{},[48,892,893],{},[58,894,895],{},"name",[48,897,898,899,682],{},"Names the hook in the report. Defaults to ",[58,900,885],{},[30,902,903,908],{},[48,904,905],{},[58,906,907],{},"on",[48,909,910,913],{},[58,911,912],{},"\u003Csource id>:\u003Cglob>"," patterns, matched against paths from the source's root. Default: any change.",[20,915,916,917,920,921,924,925,928],{},"The command gets the sync report as JSON on stdin and two variables: ",[58,918,919],{},"FLEETRC_HOOK",", the hook's name, and ",[58,922,923],{},"FLEETRC_CHANGED",", the matched ",[58,926,927],{},"\u003Csource>:\u003Cfile>"," lines, one per line. Output is kept in the report. A command that exits nonzero fails the sync, and one still running after 5 minutes is stopped.",[101,930,934],{"id":931,"anchor":932},"root-manifest-only",{"label":933,"icon":106},"Section titled \"Root manifest only\"","Root manifest only",[20,936,937,395,940,395,943,395,945,395,948,93,951,954,955,959],{},[58,938,939],{},"mcp",[58,941,942],{},"agentHooks",[58,944,96],{},[58,946,947],{},"fleet",[58,949,950],{},"hub",[58,952,953],{},"report"," run commands or name machines. A manifest you ",[51,956,958],{"href":957},"\u002Fguide\u002Fmanifest","extend"," loses them, with a warning, so a team repository cannot run code on your machine.",[961,963,964,969],{"id":103,"depth":962,"text":54},2,{"id":331,"depth":962,"text":71},{"id":654,"depth":962,"text":87,"children":965},[966,968],{"id":660,"depth":967,"text":663},3,{"id":796,"depth":967,"text":799},{"id":931,"depth":962,"text":934},{"path":971,"title":972,"description":973},"\u002Fguide\u002Fsync","Syncing","What a fleetrc sync does, from fetching your sources and linking skills into agent folders to holding your edits and writing a report.",{"path":975,"title":976,"description":977},"\u002Fguide\u002Ffleet","Fleet","Set up and sync other machines from one controller over SSH or Tailscale, check what each last ran, and run a command on all of them.",1796387377663,"d132e1fa-7946-4d59-bf8e-899a35cb66e2"]