[{"data":1,"prerenderedAt":585},["ShallowReactive",2],{"page:\u002Fextensions\u002Fkubb-labs\u002Fplugin-mcp":3},{"id":4,"frontmatter":5,"title":6,"heading":6,"body":7,"path":584,"source":4},"extensions\u002Fkubb-labs\u002Fplugin-mcp\u002Findex.md",{},"MCP",{"type":8,"value":9,"toc":575},"minimark",[10,19,54,59,145,166,170,244,248,278,297,305,309,314],[11,12,13,14,18],"p",{},"The MCP plugin turns each operation into a typed MCP tool that AI assistants can call. Each tool uses Zod schemas from ",[15,16,17],"code",{},"@kubb\u002Fplugin-zod"," for its input and output.",[11,20,21,22,25,26,29,30,33,34,37,38,40,41,44,45,47,48,50,51,53],{},"Each tool handler calls the function a client plugin generates for that operation. The plugin writes ",[15,23,24],{},"server.ts",", ",[15,27,28],{},"start.ts",", and ",[15,31,32],{},".mcp.json"," at the root of its ",[15,35,36],{},"output.path",". ",[15,39,28],{}," calls the ",[15,42,43],{},"startServer()"," that ",[15,46,24],{}," exports, and ",[15,49,32],{}," runs ",[15,52,28],{}," to start a stdio server.",[55,56,58],"h2",{"id":57},"installation","Installation",[60,61,63,92,110,128],"code-group",{"sync":62},"package-manager",[64,65,70],"pre",{"language":66,"filename":67,"code":68,"class":69},"shell","bun","bun add -d @kubb\u002Fplugin-mcp","highlights",[15,71,73],{"class":72},"language-shell",[74,75,78,82,86,89],"span",{"class":76,"style":77},"line","display: inline",[74,79,81],{"style":80},"color:#6f42c1;--hls-dark:#b392f0","bun ",[74,83,85],{"style":84},"color:#24292e;--hls-dark:#e1e4e8","add -d ",[74,87,88],{"style":84},"@",[74,90,91],{"style":84},"kubb\u002Fplugin-mcp",[64,93,96],{"language":66,"filename":94,"code":95,"class":69},"pnpm","pnpm add -D @kubb\u002Fplugin-mcp",[15,97,98],{"class":72},[74,99,100,103,106,108],{"class":76,"style":77},[74,101,102],{"style":80},"pnpm ",[74,104,105],{"style":84},"add -D ",[74,107,88],{"style":84},[74,109,91],{"style":84},[64,111,114],{"language":66,"filename":112,"code":113,"class":69},"npm","npm install --save-dev @kubb\u002Fplugin-mcp",[15,115,116],{"class":72},[74,117,118,121,124,126],{"class":76,"style":77},[74,119,120],{"style":80},"npm ",[74,122,123],{"style":84},"install --save-dev ",[74,125,88],{"style":84},[74,127,91],{"style":84},[64,129,132],{"language":66,"filename":130,"code":131,"class":69},"yarn","yarn add -D @kubb\u002Fplugin-mcp",[15,133,134],{"class":72},[74,135,136,139,141,143],{"class":76,"style":77},[74,137,138],{"style":80},"yarn ",[74,140,105],{"style":84},[74,142,88],{"style":84},[74,144,91],{"style":84},[11,146,147,148,151,152,157,158,161,162,165],{},"Or run ",[15,149,150],{},"kubb add plugin-mcp"," to install the version the ",[153,154,156],"a",{"href":155},"\u002Fregistry","Kubb registry"," pins and add ",[15,159,160],{},"pluginMcp()"," to ",[15,163,164],{},"kubb.config.ts",".",[55,167,169],{"id":168},"setup","Setup",[171,172,173,202,219,235],"ul",{},[174,175,176,177,25,179,182,183,186,187,25,190,193,194,197,198,201],"li",{},"Add ",[15,178,17],{},[15,180,181],{},"@kubb\u002Fplugin-ts"," (optional with ",[15,184,185],{},"pluginZod({ inferred: 'codec' })","), and a client plugin: ",[15,188,189],{},"@kubb\u002Fplugin-fetch",[15,191,192],{},"@kubb\u002Fplugin-axios",", or ",[15,195,196],{},"@kubb\u002Fplugin-client",". Leave ",[15,199,200],{},"sdk"," unset on the client plugin.",[174,203,204,205,208,209,212,213,216,217,165],{},"Install ",[15,206,207],{},"@modelcontextprotocol\u002Fserver"," v2 and ",[15,210,211],{},"zod"," 4.2 or a later v4 release in the app that runs the server. Add ",[15,214,215],{},"axios"," too when you use ",[15,218,192],{},[174,220,221,222,225,226,50,228,231,232,234],{},"Install a TypeScript runner such as ",[15,223,224],{},"tsx",". The generated ",[15,227,32],{},[15,229,230],{},"npx tsx",", which downloads ",[15,233,224],{}," from npm when it is missing.",[174,236,237,238,240,241,243],{},"Copy the server entry from the generated ",[15,239,32],{}," into the ",[15,242,32],{}," your MCP client reads, such as the one at the project root for Claude Code.",[55,245,247],{"id":246},"options-worth-knowing","Options worth knowing",[171,249,250,263],{},[174,251,252,255,256,259,260,262],{},[15,253,254],{},"client"," picks ",[15,257,258],{},"fetch"," or ",[15,261,215],{}," when both client plugins are registered. A single client is detected automatically.",[174,264,265,267,268,271,272,25,274,29,276,165],{},[15,266,36],{}," must be a folder name, such as the default ",[15,269,270],{},"mcp",", because single-file output has no place for ",[15,273,24],{},[15,275,28],{},[15,277,32],{},[11,279,280,281,284,285,287,288,290,291,294,295,165],{},"The ",[15,282,283],{},"args"," path in ",[15,286,32],{}," points at ",[15,289,28],{}," relative to the Kubb ",[15,292,293],{},"root",", because MCP clients start the command from their own working directory. Use an absolute path for a client that starts in another folder, or point it at your own entry file to run setup code before ",[15,296,43],{},[11,298,299,300,304],{},"See ",[153,301,303],{"href":302},"https:\u002F\u002Fkubb.dev\u002Fextensions\u002Fkubb-labs\u002Fplugin-mcp\u002Foptions","Options"," for every option and its default.",[55,306,308],{"id":307},"example","Example",[11,310,311,312,165],{},"The config below generates an MCP server whose tools call the Petstore API through ",[15,313,189],{},[64,315,318],{"language":316,"filename":164,"code":317,"class":69},"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,319,321,344,345,344,361,344,377,344,393,344,409,344,411,344,425,344,442,344,466,344,478,344,491,344,502,344,525,344,562,344,571],{"class":320},"language-typescript",[74,322,323,327,331,334,337,340],{"class":76,"style":77},[74,324,326],{"style":325},"color:#d73a49;--hls-dark:#f97583","import ",[74,328,330],{"style":329},"color:#005cc5;--hls-dark:#79b8ff","{ ",[74,332,333],{"style":84},"defineConfig ",[74,335,336],{"style":329},"} ",[74,338,339],{"style":325},"from ",[74,341,343],{"style":342},"color:#032f62;--hls-dark:#9ecbff","'kubb\u002Fconfig'","\n",[74,346,347,349,351,354,356,358],{"class":76,"style":77},[74,348,326],{"style":325},[74,350,330],{"style":329},[74,352,353],{"style":84},"pluginTs ",[74,355,336],{"style":329},[74,357,339],{"style":325},[74,359,360],{"style":342},"'@kubb\u002Fplugin-ts'",[74,362,363,365,367,370,372,374],{"class":76,"style":77},[74,364,326],{"style":325},[74,366,330],{"style":329},[74,368,369],{"style":84},"pluginZod ",[74,371,336],{"style":329},[74,373,339],{"style":325},[74,375,376],{"style":342},"'@kubb\u002Fplugin-zod'",[74,378,379,381,383,386,388,390],{"class":76,"style":77},[74,380,326],{"style":325},[74,382,330],{"style":329},[74,384,385],{"style":84},"pluginFetch ",[74,387,336],{"style":329},[74,389,339],{"style":325},[74,391,392],{"style":342},"'@kubb\u002Fplugin-fetch'",[74,394,395,397,399,402,404,406],{"class":76,"style":77},[74,396,326],{"style":325},[74,398,330],{"style":329},[74,400,401],{"style":84},"pluginMcp ",[74,403,336],{"style":329},[74,405,339],{"style":325},[74,407,408],{"style":342},"'@kubb\u002Fplugin-mcp'",[74,410],{"class":76,"style":77},[74,412,413,416,419,422],{"class":76,"style":77},[74,414,415],{"style":325},"export ",[74,417,418],{"style":325},"default ",[74,420,421],{"style":80},"defineConfig",[74,423,424],{"style":329},"({",[74,426,427,430,433,436,439],{"class":76,"style":77},[74,428,429],{"style":329},"  ",[74,431,432],{"style":329},"input",[74,434,435],{"style":325},": ",[74,437,438],{"style":342},"'.\u002FpetStore.yaml'",[74,440,441],{"style":325},",",[74,443,444,446,449,451,453,456,458,461,464],{"class":76,"style":77},[74,445,429],{"style":325},[74,447,448],{"style":329},"output",[74,450,435],{"style":325},[74,452,330],{"style":329},[74,454,455],{"style":329},"path",[74,457,435],{"style":325},[74,459,460],{"style":342},"'.\u002Fsrc\u002Fgen' ",[74,462,463],{"style":329},"}",[74,465,441],{"style":325},[74,467,468,470,473,475],{"class":76,"style":77},[74,469,429],{"style":325},[74,471,472],{"style":329},"plugins",[74,474,435],{"style":325},[74,476,477],{"style":329},"[",[74,479,480,483,486,489],{"class":76,"style":77},[74,481,482],{"style":329},"    ",[74,484,485],{"style":80},"pluginTs",[74,487,488],{"style":329},"()",[74,490,441],{"style":325},[74,492,493,495,498,500],{"class":76,"style":77},[74,494,482],{"style":325},[74,496,497],{"style":80},"pluginZod",[74,499,488],{"style":329},[74,501,441],{"style":325},[74,503,504,506,509,512,515,517,520,523],{"class":76,"style":77},[74,505,482],{"style":325},[74,507,508],{"style":80},"pluginFetch",[74,510,511],{"style":329},"({ ",[74,513,514],{"style":329},"baseURL",[74,516,435],{"style":325},[74,518,519],{"style":342},"'https:\u002F\u002Fpetstore.swagger.io\u002Fv2' ",[74,521,522],{"style":329},"})",[74,524,441],{"style":325},[74,526,527,529,532,534,536,538,540,542,544,547,549,552,554,557,560],{"class":76,"style":77},[74,528,482],{"style":325},[74,530,531],{"style":80},"pluginMcp",[74,533,511],{"style":329},[74,535,448],{"style":329},[74,537,435],{"style":325},[74,539,330],{"style":329},[74,541,455],{"style":329},[74,543,435],{"style":325},[74,545,546],{"style":342},"'mcp'",[74,548,25],{"style":325},[74,550,551],{"style":329},"mode",[74,553,435],{"style":325},[74,555,556],{"style":342},"'directory' ",[74,558,559],{"style":329},"} })",[74,561,441],{"style":325},[74,563,564,566,569],{"class":76,"style":77},[74,565,429],{"style":325},[74,567,568],{"style":329},"]",[74,570,441],{"style":325},[74,572,573],{"class":76,"style":77},[74,574,522],{"style":329},{"title":576,"searchDepth":577,"depth":577,"links":578},"",5,[579,581,582,583],{"id":57,"depth":580,"text":58},2,{"id":168,"depth":580,"text":169},{"id":246,"depth":580,"text":247},{"id":307,"depth":580,"text":308},"\u002Fextensions\u002Fkubb-labs\u002Fplugin-mcp",1793639045619]