Skip to content

Commit 4319274

Browse files
authored
feat: support new client mcp server (#2015)
* feat: add `mcp` client type as a new client * feat: add `mcp` client * chore: change main generate target from `server` to `handlers` * fix: make mcp server name dynamic * fix: dependencies in `mcp` package * docs: update `README`
1 parent bf5bbe9 commit 4319274

File tree

8 files changed

+519
-0
lines changed

8 files changed

+519
-0
lines changed

packages/core/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ export const OutputClient = {
260260
ZOD: 'zod',
261261
HONO: 'hono',
262262
FETCH: 'fetch',
263+
MCP: 'mcp',
263264
} as const;
264265

265266
export type OutputClient = (typeof OutputClient)[keyof typeof OutputClient];

packages/mcp/README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
[![npm version](https://badge.fury.io/js/orval.svg)](https://badge.fury.io/js/orval)
2+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
3+
[![tests](https://github.com/orval-labs/orval/actions/workflows/tests.yaml/badge.svg)](https://github.com/orval-labs/orval/actions/workflows/tests.yaml)
4+
5+
<p align="center">
6+
<img src="./logo/orval-logo-horizontal.svg?raw=true" width="500" height="160" alt="orval - Restfull Client Generator" />
7+
</p>
8+
<h1 align="center">
9+
Visit <a href="https://orval.dev" target="_blank">orval.dev</a> for docs, guides, API and beer!
10+
</h1>
11+
12+
### Code Generation
13+
14+
`orval` is able to generate client with appropriate type-signatures (TypeScript) from any valid OpenAPI v3 or Swagger v2 specification, either in `yaml` or `json` formats.
15+
16+
`Generate`, `valid`, `cache` and `mock` in your React, Vue, Svelte and Angular applications all with your OpenAPI specification.
17+
18+
### How to use the generated mcp server
19+
20+
Add a setting to the mcp client to launch the generated `server.ts`.
21+
For example, like this:
22+
23+
```
24+
"pet-store-server": {
25+
"command": "docker",
26+
"args": [
27+
"run",
28+
"-i",
29+
"--rm",
30+
"pet-store-mcp",
31+
"bash",
32+
"-c",
33+
"ts-node",
34+
"src/gen/server.ts"
35+
],
36+
"disabled": false,
37+
"alwaysAllow": []
38+
}
39+
```
40+
41+
Here, `src/gen/server.ts` is started using `Docker`.
42+
43+
### Samples
44+
45+
You can find below some samples
46+
47+
- [react app](https://github.com/orval-labs/orval/tree/master/samples/react-app)
48+
- [react query](https://github.com/orval-labs/orval/tree/master/samples/react-query)
49+
- [svelte query](https://github.com/orval-labs/orval/tree/master/samples/svelte-query)
50+
- [vue query](https://github.com/orval-labs/orval/tree/master/samples/vue-query)
51+
- [react app with swr](https://github.com/orval-labs/orval/tree/master/samples/react-app-with-swr)
52+
- [angular app](https://github.com/orval-labs/orval/tree/master/samples/angular-app)
53+
- [hono](https://github.com/orval-labs/orval/tree/master/samples/hono)
54+
- [next app with fetch](https://github.com/orval-labs/orval/tree/master/samples/next-app-with-fetch)

packages/mcp/package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@orval/mcp",
3+
"version": "7.8.0",
4+
"license": "MIT",
5+
"main": "./dist/index.js",
6+
"types": "./dist/index.d.ts",
7+
"files": [
8+
"dist"
9+
],
10+
"scripts": {
11+
"build": "tsup ./src/index.ts --target node12 --clean --dts --sourcemap",
12+
"dev": "tsup ./src/index.ts --target node12 --clean --watch --sourcemap src",
13+
"lint": "eslint src/**/*.ts"
14+
},
15+
"dependencies": {
16+
"@orval/core": "7.8.0",
17+
"@orval/zod": "7.8.0"
18+
}
19+
}

0 commit comments

Comments
 (0)