leanmcp 0.3.2 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +211 -184
  3. package/package.json +2 -2
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 LeanMCP Contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 LeanMCP Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,184 +1,211 @@
1
- # LeanMCP SDK
2
-
3
- A TypeScript SDK for building **Model Context Protocol (MCP)** servers with type-safe decorators and streamable HTTP support.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install leanmcp
9
- ```
10
-
11
- This meta-package includes all LeanMCP packages:
12
- - `@leanmcp/core` - Core decorators, server, and runtime
13
- - `@leanmcp/auth` - Authentication and authorization
14
- - `@leanmcp/ui` - React UI components for MCP Apps
15
- - `@leanmcp/utils` - Utility functions
16
- - `@leanmcp/elicitation` - Interactive prompts and forms
17
- - `@leanmcp/env-injection` - Environment variable management
18
-
19
- ## Quick Start
20
-
21
- ### 1. Create a new project
22
-
23
- ```bash
24
- npx @leanmcp/cli create my-mcp-server
25
- cd my-mcp-server
26
- npm install
27
- ```
28
-
29
- ### 2. Define your service
30
-
31
- ```typescript
32
- import { Tool, SchemaConstraint } from 'leanmcp';
33
-
34
- class GreetInput {
35
- @SchemaConstraint({
36
- description: 'Name to greet',
37
- minLength: 1
38
- })
39
- name!: string;
40
- }
41
-
42
- export class GreetingService {
43
- @Tool({
44
- description: 'Greet someone',
45
- inputClass: GreetInput
46
- })
47
- async greet(args: GreetInput) {
48
- return { message: `Hello, ${args.name}!` };
49
- }
50
- }
51
- ```
52
-
53
- ### 3. Run your server
54
-
55
- ```bash
56
- npm start
57
- ```
58
-
59
- Your MCP server starts on `http://localhost:8080` with:
60
- - HTTP endpoint: `http://localhost:8080/mcp`
61
- - Health check: `http://localhost:8080/health`
62
-
63
- ## Features
64
-
65
- - **Type-safe decorators** - Full TypeScript support with compile-time validation
66
- - **Declarative schema definition** - Define JSON Schema using `@SchemaConstraint` decorators
67
- - **Clean API** - Function names become tool/prompt/resource names automatically
68
- - **MCP compliant** - Built on official @modelcontextprotocol/sdk
69
- - **Streamable HTTP** - Production-ready HTTP server with session management
70
- - **Authentication** - Built-in `@Authenticated` decorator with multi-provider support
71
- - **Interactive CLI** - Guided project setup with dependency installation
72
- - **React UI Components** - Build interactive MCP apps with pre-built components
73
- - **Built-in validation** - Automatic input validation using defined schemas
74
-
75
- ## Usage Examples
76
-
77
- ### Core Server
78
-
79
- ```typescript
80
- import { createHTTPServer, Tool } from 'leanmcp';
81
-
82
- // Services are automatically discovered from ./mcp directory
83
- await createHTTPServer({
84
- name: "my-mcp-server",
85
- version: "1.0.0",
86
- port: 8080,
87
- cors: true,
88
- logging: true
89
- });
90
- ```
91
-
92
- ### Authentication
93
-
94
- ```typescript
95
- import { Tool, AuthProvider, Authenticated } from 'leanmcp';
96
-
97
- const authProvider = new AuthProvider('cognito', {
98
- region: process.env.AWS_REGION,
99
- userPoolId: process.env.COGNITO_USER_POOL_ID,
100
- clientId: process.env.COGNITO_CLIENT_ID
101
- });
102
- await authProvider.init();
103
-
104
- @Authenticated(authProvider)
105
- export class SecureService {
106
- @Tool({ description: 'Protected endpoint' })
107
- async protectedMethod(args: any) {
108
- return { success: true };
109
- }
110
- }
111
- ```
112
-
113
- ### React UI Components
114
-
115
- ```typescript
116
- import { AppProvider, AppShell, HTTPTransport } from 'leanmcp/ui';
117
- import 'leanmcp/ui/styles.css';
118
-
119
- function App() {
120
- const transport = new HTTPTransport('http://localhost:8080/mcp');
121
-
122
- return (
123
- <AppProvider transport={transport}>
124
- <AppShell />
125
- </AppProvider>
126
- );
127
- }
128
- ```
129
-
130
- ## Package Exports
131
-
132
- ### Main Export
133
-
134
- ```typescript
135
- import { createHTTPServer, Tool, Prompt, Resource } from 'leanmcp';
136
- ```
137
-
138
- ### UI Components
139
-
140
- ```typescript
141
- import { AppProvider, AppShell } from 'leanmcp/ui';
142
- import 'leanmcp/ui/styles.css';
143
- ```
144
-
145
- ### Individual Packages
146
-
147
- You can also install individual packages if you only need specific functionality:
148
-
149
- ```bash
150
- npm install @leanmcp/core # Core decorators and server
151
- npm install @leanmcp/auth # Authentication
152
- npm install @leanmcp/ui # React UI components
153
- npm install @leanmcp/cli # CLI tools
154
- ```
155
-
156
- ## Documentation
157
-
158
- For complete documentation, examples, and API reference, visit:
159
- - [GitHub Repository](https://github.com/LeanMCP/leanmcp-sdk)
160
- - [Full Documentation](https://github.com/LeanMCP/leanmcp-sdk#readme)
161
-
162
- ## CLI Commands
163
-
164
- ### Create a new project
165
-
166
- ```bash
167
- npx @leanmcp/cli create my-mcp-server
168
- ```
169
-
170
- ### Add a service to existing project
171
-
172
- ```bash
173
- npx @leanmcp/cli add weather
174
- ```
175
-
176
- ## License
177
-
178
- MIT
179
-
180
- ## Links
181
-
182
- - [MCP Specification](https://modelcontextprotocol.io/)
183
- - [GitHub Repository](https://github.com/LeanMCP/leanmcp-sdk)
184
- - [Issues](https://github.com/LeanMCP/leanmcp-sdk/issues)
1
+ <p align="center">
2
+ <img
3
+ src="https://raw.githubusercontent.com/LeanMCP/leanmcp-sdk/refs/heads/main/assets/logo.png"
4
+ alt="LeanMCP Logo"
5
+ width="400"
6
+ />
7
+ </p>
8
+
9
+ <p align="center">
10
+ <strong>leanmcp</strong><br/>
11
+ TypeScript SDK for building Model Context Protocol (MCP) servers.
12
+ </p>
13
+
14
+ <p align="center">
15
+ <a href="https://www.npmjs.com/package/leanmcp">
16
+ <img src="https://img.shields.io/npm/v/leanmcp" alt="npm version" />
17
+ </a>
18
+ <a href="https://www.npmjs.com/package/leanmcp">
19
+ <img src="https://img.shields.io/npm/dm/leanmcp" alt="npm downloads" />
20
+ </a>
21
+ <a href="https://docs.leanmcp.com">
22
+ <img src="https://img.shields.io/badge/Docs-leanmcp-0A66C2?" />
23
+ </a>
24
+ <a href="https://discord.com/invite/DsRcA3GwPy">
25
+ <img src="https://img.shields.io/badge/Discord-Join-5865F2?logo=discord&logoColor=white" />
26
+ </a>
27
+ <a href="https://x.com/LeanMcp">
28
+ <img src="https://img.shields.io/badge/@LeanMCP-f5f5f5?logo=x&logoColor=000000" />
29
+ </a>
30
+ </p>
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ npm install leanmcp
36
+ ```
37
+
38
+ This meta-package includes all LeanMCP packages:
39
+ - `@leanmcp/core` — Core decorators (`@Tool`, `@Prompt`, `@Resource`) and HTTP server
40
+ - `@leanmcp/auth` — Authentication with Cognito, Clerk, Auth0, LeanMCP providers
41
+ - `@leanmcp/ui` — MCP-native React components, hooks, and `@UIApp`/`@GPTApp` decorators
42
+ - `@leanmcp/utils` Utility functions (retry, formatting, async helpers)
43
+ - `@leanmcp/elicitation` — Structured user input collection with `@Elicitation`
44
+ - `@leanmcp/env-injection` — Request-scoped environment variables with `@RequireEnv`
45
+
46
+ ## Quick Start
47
+
48
+ ### 1. Create a new project
49
+
50
+ ```bash
51
+ npx @leanmcp/cli create my-mcp-server
52
+ cd my-mcp-server
53
+ npm install
54
+ ```
55
+
56
+ ### 2. Define your service
57
+
58
+ ```typescript
59
+ import { Tool, SchemaConstraint } from 'leanmcp';
60
+
61
+ class GreetInput {
62
+ @SchemaConstraint({
63
+ description: 'Name to greet',
64
+ minLength: 1
65
+ })
66
+ name!: string;
67
+ }
68
+
69
+ export class GreetingService {
70
+ @Tool({
71
+ description: 'Greet someone',
72
+ inputClass: GreetInput
73
+ })
74
+ async greet(args: GreetInput) {
75
+ return { message: `Hello, ${args.name}!` };
76
+ }
77
+ }
78
+ ```
79
+
80
+ ### 3. Run your server
81
+
82
+ ```bash
83
+ npm start
84
+ ```
85
+
86
+ Your MCP server starts on `http://localhost:8080` with:
87
+ - HTTP endpoint: `http://localhost:8080/mcp`
88
+ - Health check: `http://localhost:8080/health`
89
+
90
+ ## Features
91
+
92
+ - **Type-safe decorators** - Full TypeScript support with compile-time validation
93
+ - **Declarative schema definition** - Define JSON Schema using `@SchemaConstraint` decorators
94
+ - **Clean API** - Function names become tool/prompt/resource names automatically
95
+ - **MCP compliant** - Built on official @modelcontextprotocol/sdk
96
+ - **Streamable HTTP** - Production-ready HTTP server with session management
97
+ - **Authentication** - Built-in `@Authenticated` decorator with multi-provider support
98
+ - **Interactive CLI** - Guided project setup with dependency installation
99
+ - **React UI Components** - Build interactive MCP apps with pre-built components
100
+ - **Built-in validation** - Automatic input validation using defined schemas
101
+
102
+ ## Usage Examples
103
+
104
+ ### Core Server
105
+
106
+ ```typescript
107
+ import { createHTTPServer, Tool } from 'leanmcp';
108
+
109
+ // Services are automatically discovered from ./mcp directory
110
+ await createHTTPServer({
111
+ name: "my-mcp-server",
112
+ version: "1.0.0",
113
+ port: 8080,
114
+ cors: true,
115
+ logging: true
116
+ });
117
+ ```
118
+
119
+ ### Authentication
120
+
121
+ ```typescript
122
+ import { Tool, AuthProvider, Authenticated } from 'leanmcp';
123
+
124
+ const authProvider = new AuthProvider('cognito', {
125
+ region: process.env.AWS_REGION,
126
+ userPoolId: process.env.COGNITO_USER_POOL_ID,
127
+ clientId: process.env.COGNITO_CLIENT_ID
128
+ });
129
+ await authProvider.init();
130
+
131
+ @Authenticated(authProvider)
132
+ export class SecureService {
133
+ @Tool({ description: 'Protected endpoint' })
134
+ async protectedMethod(args: any) {
135
+ return { success: true };
136
+ }
137
+ }
138
+ ```
139
+
140
+ ### React UI Components
141
+
142
+ ```typescript
143
+ import { AppProvider, AppShell, HTTPTransport } from 'leanmcp/ui';
144
+ import 'leanmcp/ui/styles.css';
145
+
146
+ function App() {
147
+ const transport = new HTTPTransport('http://localhost:8080/mcp');
148
+
149
+ return (
150
+ <AppProvider transport={transport}>
151
+ <AppShell />
152
+ </AppProvider>
153
+ );
154
+ }
155
+ ```
156
+
157
+ ## Package Exports
158
+
159
+ ### Main Export
160
+
161
+ ```typescript
162
+ import { createHTTPServer, Tool, Prompt, Resource } from 'leanmcp';
163
+ ```
164
+
165
+ ### UI Components
166
+
167
+ ```typescript
168
+ import { AppProvider, AppShell } from 'leanmcp/ui';
169
+ import 'leanmcp/ui/styles.css';
170
+ ```
171
+
172
+ ### Individual Packages
173
+
174
+ You can also install individual packages if you only need specific functionality:
175
+
176
+ ```bash
177
+ npm install @leanmcp/core # Core decorators and server
178
+ npm install @leanmcp/auth # Authentication
179
+ npm install @leanmcp/ui # React UI components
180
+ npm install @leanmcp/cli # CLI tools
181
+ ```
182
+
183
+ ## Documentation
184
+
185
+ For complete documentation, examples, and API reference, visit:
186
+ - [GitHub Repository](https://github.com/LeanMCP/leanmcp-sdk)
187
+ - [Full Documentation](https://github.com/LeanMCP/leanmcp-sdk#readme)
188
+
189
+ ## CLI Commands
190
+
191
+ ### Create a new project
192
+
193
+ ```bash
194
+ npx @leanmcp/cli create my-mcp-server
195
+ ```
196
+
197
+ ### Add a service to existing project
198
+
199
+ ```bash
200
+ npx @leanmcp/cli add weather
201
+ ```
202
+
203
+ ## License
204
+
205
+ MIT
206
+
207
+ ## Links
208
+
209
+ - [MCP Specification](https://modelcontextprotocol.io/)
210
+ - [GitHub Repository](https://github.com/LeanMCP/leanmcp-sdk)
211
+ - [Issues](https://github.com/LeanMCP/leanmcp-sdk/issues)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leanmcp",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "LeanMCP SDK - TypeScript SDK for building Model Context Protocol (MCP) servers with type-safe decorators",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -66,4 +66,4 @@
66
66
  "publishConfig": {
67
67
  "access": "public"
68
68
  }
69
- }
69
+ }