[{"data":1,"prerenderedAt":805},["ShallowReactive",2],{"page:\u002Fextensions\u002Fkubb-labs\u002Fplugin-mcp":3},{"id":4,"frontmatter":5,"title":6,"heading":6,"body":7,"path":804,"source":4},"extensions\u002Fkubb-labs\u002Fplugin-mcp\u002Findex.md",{},"MCP",{"type":8,"value":9,"toc":795},"minimark",[10,19,22,29,89,94,194,224,228,308,312,400,403,410,414,426,787],[11,12,13,14,18],"p",{},"The MCP plugin turns each operation in your OpenAPI spec into a typed MCP tool that AI assistants can call, validated with ",[15,16,17],"code",{},"@kubb\u002Fplugin-zod"," schemas.",[11,20,21],{},"Each tool handler calls the function a client plugin generates for that operation.",[11,23,24,25,28],{},"Next to the handlers, the plugin writes three files at the root of its ",[15,26,27],{},"output.path",":",[30,31,32,45],"table",{},[33,34,35],"thead",{},[36,37,38,42],"tr",{},[39,40,41],"th",{},"File",[39,43,44],{},"Role",[46,47,48,63,76],"tbody",{},[36,49,50,56],{},[51,52,53],"td",{},[15,54,55],{},"server.ts",[51,57,58,59,62],{},"Registers one tool per operation and exports ",[15,60,61],{},"startServer()",".",[36,64,65,70],{},[51,66,67],{},[15,68,69],{},"start.ts",[51,71,72,73,75],{},"Calls ",[15,74,61],{}," to serve the tools over stdio.",[36,77,78,83],{},[51,79,80],{},[15,81,82],{},".mcp.json",[51,84,85,86,88],{},"A server entry that runs ",[15,87,69],{},", ready to copy into your MCP client config.",[90,91,93],"h2",{"id":92},"installation","Installation",[95,96,98,121,141,159,177],"code-group",{"sync":97},"install",[99,100,105],"pre",{"language":101,"filename":102,"code":103,"class":104},"shell","kubb","kubb add plugin-mcp","highlights",[15,106,108],{"class":107},"language-shell",[109,110,113,117],"span",{"class":111,"style":112},"line","display: inline",[109,114,116],{"style":115},"color:#6f42c1;--hls-dark:#b392f0","kubb ",[109,118,120],{"style":119},"color:#24292e;--hls-dark:#e1e4e8","add plugin-mcp",[99,122,125],{"language":101,"filename":123,"code":124,"class":104},"bun","bun add -d @kubb\u002Fplugin-mcp",[15,126,127],{"class":107},[109,128,129,132,135,138],{"class":111,"style":112},[109,130,131],{"style":115},"bun ",[109,133,134],{"style":119},"add -d ",[109,136,137],{"style":119},"@",[109,139,140],{"style":119},"kubb\u002Fplugin-mcp",[99,142,145],{"language":101,"filename":143,"code":144,"class":104},"pnpm","pnpm add -D @kubb\u002Fplugin-mcp",[15,146,147],{"class":107},[109,148,149,152,155,157],{"class":111,"style":112},[109,150,151],{"style":115},"pnpm ",[109,153,154],{"style":119},"add -D ",[109,156,137],{"style":119},[109,158,140],{"style":119},[99,160,163],{"language":101,"filename":161,"code":162,"class":104},"npm","npm install --save-dev @kubb\u002Fplugin-mcp",[15,164,165],{"class":107},[109,166,167,170,173,175],{"class":111,"style":112},[109,168,169],{"style":115},"npm ",[109,171,172],{"style":119},"install --save-dev ",[109,174,137],{"style":119},[109,176,140],{"style":119},[99,178,181],{"language":101,"filename":179,"code":180,"class":104},"yarn","yarn add -D @kubb\u002Fplugin-mcp",[15,182,183],{"class":107},[109,184,185,188,190,192],{"class":111,"style":112},[109,186,187],{"style":115},"yarn ",[109,189,154],{"style":119},[109,191,137],{"style":119},[109,193,140],{"style":119},[11,195,196,199,200,205,206,209,210,213,214,216,217,223],{},[15,197,198],{},"kubb add"," installs the version the ",[201,202,204],"a",{"href":203},"\u002Fregistry","Kubb registry"," pins and adds ",[15,207,208],{},"pluginMcp()"," to ",[15,211,212],{},"kubb.config.ts",". It needs a ",[15,215,212],{},", so run ",[201,218,220],{"href":219},"\u002Fdocs\u002F5.x\u002Freference\u002Fcommands\u002Finit",[15,221,222],{},"kubb init"," first in a new project.",[90,225,227],{"id":226},"setup","Setup",[229,230,231,268,291],"ul",{},[232,233,234,235,237,238,241,242,241,245,248,249,252,253,256,257,259,260,263,264,267],"li",{},"Add ",[15,236,17],{},", one client plugin (",[15,239,240],{},"@kubb\u002Fplugin-fetch",", ",[15,243,244],{},"@kubb\u002Fplugin-axios",[15,246,247],{},"@kubb\u002Fplugin-ky",", or ",[15,250,251],{},"@kubb\u002Fplugin-client","), and ",[15,254,255],{},"@kubb\u002Fplugin-ts",". ",[15,258,255],{}," is optional with ",[15,261,262],{},"pluginZod({ inferred: 'codec' })",". Leave ",[15,265,266],{},"sdk"," unset on the client plugin.",[232,269,270,271,274,275,278,279,282,283,286,287,282,289,62],{},"Install ",[15,272,273],{},"@modelcontextprotocol\u002Fserver"," v2 and ",[15,276,277],{},"zod"," 4.2 or a later v4 release in the app that runs the server. Add ",[15,280,281],{},"axios"," or ",[15,284,285],{},"ky"," too when you use ",[15,288,244],{},[15,290,247],{},[232,292,293,294,297,298,300,301,304,305,307],{},"Install a TypeScript runner such as ",[15,295,296],{},"tsx",". The generated ",[15,299,82],{}," runs ",[15,302,303],{},"npx tsx",", which downloads ",[15,306,296],{}," from npm when it is missing.",[90,309,311],{"id":310},"options-worth-knowing","Options worth knowing",[30,313,314,327],{},[33,315,316],{},[36,317,318,321,324],{},[39,319,320],{},"Option",[39,322,323],{},"Default",[39,325,326],{},"What it does",[46,328,329,358,376],{},[36,330,331,339,342],{},[51,332,333],{},[201,334,336],{"href":335},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-mcp\u002Foptions#client",[15,337,338],{},"client",[51,340,341],{},"Detected",[51,343,344,345,241,348,241,351,248,354,357],{},"Picks ",[15,346,347],{},"'fetch'",[15,349,350],{},"'axios'",[15,352,353],{},"'ky'",[15,355,356],{},"'client'"," when several client plugins are registered.",[36,359,360,368,373],{},[51,361,362],{},[201,363,365],{"href":364},"https:\u002F\u002Fkubb.dev\u002Fdocs\u002F5.x\u002Freference\u002Fplugin-options#exclude",[15,366,367],{},"exclude",[51,369,370],{},[15,371,372],{},"[]",[51,374,375],{},"Skips operations, such as one with a binary request body. An MCP client sends JSON and cannot send a file.",[36,377,378,385,390],{},[51,379,380],{},[201,381,383],{"href":382},"https:\u002F\u002Fkubb.dev\u002Fdocs\u002F5.x\u002Freference\u002Fplugin-options#output",[15,384,27],{},[51,386,387],{},[15,388,389],{},"'mcp'",[51,391,392,393,241,395,397,398,62],{},"Must name a folder for ",[15,394,55],{},[15,396,69],{},", and ",[15,399,82],{},[11,401,402],{},"Operations that stream their response get no tool.",[11,404,405,406,62],{},"See ",[201,407,409],{"href":408},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-mcp\u002Fguides\u002Fserver#streaming-operations","Streaming operations",[90,411,413],{"id":412},"example","Example",[11,415,416,417,419,420,422,423,28],{},"This config generates an MCP server whose tools call the Petstore API through ",[15,418,240],{},". The ",[15,421,82],{}," names the server after the spec's ",[15,424,425],{},"info.title",[95,427,428,688],{},[99,429,432],{"language":430,"filename":212,"code":431,"class":104},"typescript","import { defineConfig } from 'kubb\u002Fconfig'\nimport { pluginTs } from '@kubb\u002Fplugin-ts'\nimport { pluginZod } from '@kubb\u002Fplugin-zod'\nimport { pluginFetch } from '@kubb\u002Fplugin-fetch'\nimport { pluginMcp } from '@kubb\u002Fplugin-mcp'\n\nexport default defineConfig({\n  input: '.\u002FpetStore.yaml',\n  output: { path: '.\u002Fsrc\u002Fgen' },\n  plugins: [\n    pluginTs(),\n    pluginZod(),\n    pluginFetch({ baseURL: 'https:\u002F\u002Fpetstore.swagger.io\u002Fv2' }),\n    pluginMcp({ output: { path: 'mcp', mode: 'directory' } }),\n  ],\n})",[15,433,435,458,459,458,475,458,491,458,507,458,523,458,525,458,539,458,556,458,580,458,592,458,605,458,616,458,639,458,675,458,684],{"class":434},"language-typescript",[109,436,437,441,445,448,451,454],{"class":111,"style":112},[109,438,440],{"style":439},"color:#d73a49;--hls-dark:#f97583","import ",[109,442,444],{"style":443},"color:#005cc5;--hls-dark:#79b8ff","{ ",[109,446,447],{"style":119},"defineConfig ",[109,449,450],{"style":443},"} ",[109,452,453],{"style":439},"from ",[109,455,457],{"style":456},"color:#032f62;--hls-dark:#9ecbff","'kubb\u002Fconfig'","\n",[109,460,461,463,465,468,470,472],{"class":111,"style":112},[109,462,440],{"style":439},[109,464,444],{"style":443},[109,466,467],{"style":119},"pluginTs ",[109,469,450],{"style":443},[109,471,453],{"style":439},[109,473,474],{"style":456},"'@kubb\u002Fplugin-ts'",[109,476,477,479,481,484,486,488],{"class":111,"style":112},[109,478,440],{"style":439},[109,480,444],{"style":443},[109,482,483],{"style":119},"pluginZod ",[109,485,450],{"style":443},[109,487,453],{"style":439},[109,489,490],{"style":456},"'@kubb\u002Fplugin-zod'",[109,492,493,495,497,500,502,504],{"class":111,"style":112},[109,494,440],{"style":439},[109,496,444],{"style":443},[109,498,499],{"style":119},"pluginFetch ",[109,501,450],{"style":443},[109,503,453],{"style":439},[109,505,506],{"style":456},"'@kubb\u002Fplugin-fetch'",[109,508,509,511,513,516,518,520],{"class":111,"style":112},[109,510,440],{"style":439},[109,512,444],{"style":443},[109,514,515],{"style":119},"pluginMcp ",[109,517,450],{"style":443},[109,519,453],{"style":439},[109,521,522],{"style":456},"'@kubb\u002Fplugin-mcp'",[109,524],{"class":111,"style":112},[109,526,527,530,533,536],{"class":111,"style":112},[109,528,529],{"style":439},"export ",[109,531,532],{"style":439},"default ",[109,534,535],{"style":115},"defineConfig",[109,537,538],{"style":443},"({",[109,540,541,544,547,550,553],{"class":111,"style":112},[109,542,543],{"style":443},"  ",[109,545,546],{"style":443},"input",[109,548,549],{"style":439},": ",[109,551,552],{"style":456},"'.\u002FpetStore.yaml'",[109,554,555],{"style":439},",",[109,557,558,560,563,565,567,570,572,575,578],{"class":111,"style":112},[109,559,543],{"style":439},[109,561,562],{"style":443},"output",[109,564,549],{"style":439},[109,566,444],{"style":443},[109,568,569],{"style":443},"path",[109,571,549],{"style":439},[109,573,574],{"style":456},"'.\u002Fsrc\u002Fgen' ",[109,576,577],{"style":443},"}",[109,579,555],{"style":439},[109,581,582,584,587,589],{"class":111,"style":112},[109,583,543],{"style":439},[109,585,586],{"style":443},"plugins",[109,588,549],{"style":439},[109,590,591],{"style":443},"[",[109,593,594,597,600,603],{"class":111,"style":112},[109,595,596],{"style":443},"    ",[109,598,599],{"style":115},"pluginTs",[109,601,602],{"style":443},"()",[109,604,555],{"style":439},[109,606,607,609,612,614],{"class":111,"style":112},[109,608,596],{"style":439},[109,610,611],{"style":115},"pluginZod",[109,613,602],{"style":443},[109,615,555],{"style":439},[109,617,618,620,623,626,629,631,634,637],{"class":111,"style":112},[109,619,596],{"style":439},[109,621,622],{"style":115},"pluginFetch",[109,624,625],{"style":443},"({ ",[109,627,628],{"style":443},"baseURL",[109,630,549],{"style":439},[109,632,633],{"style":456},"'https:\u002F\u002Fpetstore.swagger.io\u002Fv2' ",[109,635,636],{"style":443},"})",[109,638,555],{"style":439},[109,640,641,643,646,648,650,652,654,656,658,660,662,665,667,670,673],{"class":111,"style":112},[109,642,596],{"style":439},[109,644,645],{"style":115},"pluginMcp",[109,647,625],{"style":443},[109,649,562],{"style":443},[109,651,549],{"style":439},[109,653,444],{"style":443},[109,655,569],{"style":443},[109,657,549],{"style":439},[109,659,389],{"style":456},[109,661,241],{"style":439},[109,663,664],{"style":443},"mode",[109,666,549],{"style":439},[109,668,669],{"style":456},"'directory' ",[109,671,672],{"style":443},"} })",[109,674,555],{"style":439},[109,676,677,679,682],{"class":111,"style":112},[109,678,543],{"style":439},[109,680,681],{"style":443},"]",[109,683,555],{"style":439},[109,685,686],{"class":111,"style":112},[109,687,636],{"style":443},[99,689,693],{"language":690,"filename":691,"code":692,"class":104},"json","src\u002Fgen\u002Fmcp\u002F.mcp.json","{\n  \"mcpServers\": {\n    \"Swagger Petstore\": {\n      \"type\": \"stdio\",\n      \"command\": \"npx\",\n      \"args\": [\"tsx\", \".\u002Fsrc\u002Fgen\u002Fmcp\u002Fstart.ts\"]\n    }\n  }\n}",[15,694,696,458,701,458,712,458,723,458,738,458,752,458,773,458,778,458,783],{"class":695},"language-json",[109,697,698],{"class":111,"style":112},[109,699,700],{"style":443},"{",[109,702,703,705,708,710],{"class":111,"style":112},[109,704,543],{"style":443},[109,706,707],{"style":443},"\"mcpServers\"",[109,709,549],{"style":439},[109,711,700],{"style":443},[109,713,714,716,719,721],{"class":111,"style":112},[109,715,596],{"style":443},[109,717,718],{"style":443},"\"Swagger Petstore\"",[109,720,549],{"style":439},[109,722,700],{"style":443},[109,724,725,728,731,733,736],{"class":111,"style":112},[109,726,727],{"style":443},"      ",[109,729,730],{"style":443},"\"type\"",[109,732,549],{"style":439},[109,734,735],{"style":456},"\"stdio\"",[109,737,555],{"style":439},[109,739,740,742,745,747,750],{"class":111,"style":112},[109,741,727],{"style":439},[109,743,744],{"style":443},"\"command\"",[109,746,549],{"style":439},[109,748,749],{"style":456},"\"npx\"",[109,751,555],{"style":439},[109,753,754,756,759,761,763,766,768,771],{"class":111,"style":112},[109,755,727],{"style":439},[109,757,758],{"style":443},"\"args\"",[109,760,549],{"style":439},[109,762,591],{"style":443},[109,764,765],{"style":456},"\"tsx\"",[109,767,241],{"style":439},[109,769,770],{"style":456},"\".\u002Fsrc\u002Fgen\u002Fmcp\u002Fstart.ts\"",[109,772,681],{"style":443},[109,774,775],{"class":111,"style":112},[109,776,777],{"style":443},"    }",[109,779,780],{"class":111,"style":112},[109,781,782],{"style":443},"  }",[109,784,785],{"class":111,"style":112},[109,786,577],{"style":443},[11,788,789,790,794],{},"Next, ",[201,791,793],{"href":792},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-mcp\u002Fguides\u002Fserver","run the server"," and connect Claude Code or Claude Desktop.",{"title":796,"searchDepth":797,"depth":797,"links":798},"",5,[799,801,802,803],{"id":92,"depth":800,"text":93},2,{"id":226,"depth":800,"text":227},{"id":310,"depth":800,"text":311},{"id":412,"depth":800,"text":413},"\u002Fextensions\u002Fkubb-labs\u002Fplugin-mcp",1795448485189]