leanmcp 0.3.1

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.
package/LICENSE ADDED
@@ -0,0 +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.
package/README.md ADDED
@@ -0,0 +1,184 @@
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)
@@ -0,0 +1,9 @@
1
+ export * from '@leanmcp/core';
2
+ export { MCPServer, MCPServerConstructorOptions, Optional, Prompt, Resource, SchemaConstraint, Tool, createHTTPServer } from '@leanmcp/core';
3
+ export * from '@leanmcp/auth';
4
+ export { AuthProvider, AuthProviderBase, Authenticated, AuthenticatedOptions } from '@leanmcp/auth';
5
+ export * from '@leanmcp/ui';
6
+ export { ActionButton, AppProvider, AppProviderProps, AppShell, AppShellProps, Button, Card, CardContent, CardFooter, CardHeader, Chart, CodeBlock, DataGrid, HTTPTransport, HTTPTransportConfig, Input, MCPPrompt, MCPResource, MCPTool, ToolForm, useMcpApp, useTool, useToolSubscription } from '@leanmcp/ui';
7
+ export * from '@leanmcp/utils';
8
+ export * from '@leanmcp/elicitation';
9
+ export * from '@leanmcp/env-injection';
@@ -0,0 +1,9 @@
1
+ export * from '@leanmcp/core';
2
+ export { MCPServer, MCPServerConstructorOptions, Optional, Prompt, Resource, SchemaConstraint, Tool, createHTTPServer } from '@leanmcp/core';
3
+ export * from '@leanmcp/auth';
4
+ export { AuthProvider, AuthProviderBase, Authenticated, AuthenticatedOptions } from '@leanmcp/auth';
5
+ export * from '@leanmcp/ui';
6
+ export { ActionButton, AppProvider, AppProviderProps, AppShell, AppShellProps, Button, Card, CardContent, CardFooter, CardHeader, Chart, CodeBlock, DataGrid, HTTPTransport, HTTPTransportConfig, Input, MCPPrompt, MCPResource, MCPTool, ToolForm, useMcpApp, useTool, useToolSubscription } from '@leanmcp/ui';
7
+ export * from '@leanmcp/utils';
8
+ export * from '@leanmcp/elicitation';
9
+ export * from '@leanmcp/env-injection';
package/dist/index.js ADDED
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.ts
22
+ var index_exports = {};
23
+ __export(index_exports, {
24
+ ActionButton: () => import_ui.ActionButton,
25
+ AppProvider: () => import_ui.AppProvider,
26
+ AppShell: () => import_ui.AppShell,
27
+ AuthProvider: () => import_auth.AuthProvider,
28
+ AuthProviderBase: () => import_auth.AuthProviderBase,
29
+ Authenticated: () => import_auth.Authenticated,
30
+ Button: () => import_ui.Button,
31
+ Card: () => import_ui.Card,
32
+ CardContent: () => import_ui.CardContent,
33
+ CardFooter: () => import_ui.CardFooter,
34
+ CardHeader: () => import_ui.CardHeader,
35
+ Chart: () => import_ui.Chart,
36
+ CodeBlock: () => import_ui.CodeBlock,
37
+ DataGrid: () => import_ui.DataGrid,
38
+ HTTPTransport: () => import_ui.HTTPTransport,
39
+ Input: () => import_ui.Input,
40
+ MCPServer: () => import_core.MCPServer,
41
+ Optional: () => import_core.Optional,
42
+ Prompt: () => import_core.Prompt,
43
+ Resource: () => import_core.Resource,
44
+ SchemaConstraint: () => import_core.SchemaConstraint,
45
+ Tool: () => import_core.Tool,
46
+ ToolForm: () => import_ui.ToolForm,
47
+ createHTTPServer: () => import_core.createHTTPServer,
48
+ useMcpApp: () => import_ui.useMcpApp,
49
+ useTool: () => import_ui.useTool,
50
+ useToolSubscription: () => import_ui.useToolSubscription
51
+ });
52
+ module.exports = __toCommonJS(index_exports);
53
+ __reExport(index_exports, require("@leanmcp/core"), module.exports);
54
+ var import_core = require("@leanmcp/core");
55
+ __reExport(index_exports, require("@leanmcp/auth"), module.exports);
56
+ var import_auth = require("@leanmcp/auth");
57
+ __reExport(index_exports, require("@leanmcp/ui"), module.exports);
58
+ var import_ui = require("@leanmcp/ui");
59
+ __reExport(index_exports, require("@leanmcp/utils"), module.exports);
60
+ __reExport(index_exports, require("@leanmcp/elicitation"), module.exports);
61
+ __reExport(index_exports, require("@leanmcp/env-injection"), module.exports);
62
+ // Annotate the CommonJS export names for ESM import in node:
63
+ 0 && (module.exports = {
64
+ ActionButton,
65
+ AppProvider,
66
+ AppShell,
67
+ AuthProvider,
68
+ AuthProviderBase,
69
+ Authenticated,
70
+ Button,
71
+ Card,
72
+ CardContent,
73
+ CardFooter,
74
+ CardHeader,
75
+ Chart,
76
+ CodeBlock,
77
+ DataGrid,
78
+ HTTPTransport,
79
+ Input,
80
+ MCPServer,
81
+ Optional,
82
+ Prompt,
83
+ Resource,
84
+ SchemaConstraint,
85
+ Tool,
86
+ ToolForm,
87
+ createHTTPServer,
88
+ useMcpApp,
89
+ useTool,
90
+ useToolSubscription,
91
+ ...require("@leanmcp/core"),
92
+ ...require("@leanmcp/auth"),
93
+ ...require("@leanmcp/ui"),
94
+ ...require("@leanmcp/utils"),
95
+ ...require("@leanmcp/elicitation"),
96
+ ...require("@leanmcp/env-injection")
97
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,65 @@
1
+ // src/index.ts
2
+ export * from "@leanmcp/core";
3
+ import {
4
+ createHTTPServer,
5
+ MCPServer,
6
+ Tool,
7
+ Prompt,
8
+ Resource,
9
+ Optional,
10
+ SchemaConstraint
11
+ } from "@leanmcp/core";
12
+ export * from "@leanmcp/auth";
13
+ import { AuthProvider, AuthProviderBase, Authenticated } from "@leanmcp/auth";
14
+ export * from "@leanmcp/ui";
15
+ import {
16
+ AppProvider,
17
+ useMcpApp,
18
+ AppShell,
19
+ HTTPTransport,
20
+ useTool,
21
+ useToolSubscription,
22
+ ActionButton,
23
+ ToolForm,
24
+ Button,
25
+ Card,
26
+ CardHeader,
27
+ CardContent,
28
+ CardFooter,
29
+ Input,
30
+ DataGrid,
31
+ Chart,
32
+ CodeBlock
33
+ } from "@leanmcp/ui";
34
+ export * from "@leanmcp/utils";
35
+ export * from "@leanmcp/elicitation";
36
+ export * from "@leanmcp/env-injection";
37
+ export {
38
+ ActionButton,
39
+ AppProvider,
40
+ AppShell,
41
+ AuthProvider,
42
+ AuthProviderBase,
43
+ Authenticated,
44
+ Button,
45
+ Card,
46
+ CardContent,
47
+ CardFooter,
48
+ CardHeader,
49
+ Chart,
50
+ CodeBlock,
51
+ DataGrid,
52
+ HTTPTransport,
53
+ Input,
54
+ MCPServer,
55
+ Optional,
56
+ Prompt,
57
+ Resource,
58
+ SchemaConstraint,
59
+ Tool,
60
+ ToolForm,
61
+ createHTTPServer,
62
+ useMcpApp,
63
+ useTool,
64
+ useToolSubscription
65
+ };
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "leanmcp",
3
+ "version": "0.3.1",
4
+ "description": "LeanMCP SDK - TypeScript SDK for building Model Context Protocol (MCP) servers with type-safe decorators",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "require": "./dist/index.js",
12
+ "import": "./dist/index.mjs"
13
+ },
14
+ "./ui": {
15
+ "types": "./node_modules/@leanmcp/ui/dist/index.d.ts",
16
+ "require": "./node_modules/@leanmcp/ui/dist/index.js",
17
+ "import": "./node_modules/@leanmcp/ui/dist/index.mjs"
18
+ },
19
+ "./ui/styles.css": "./node_modules/@leanmcp/ui/dist/index.css"
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "README.md",
24
+ "LICENSE"
25
+ ],
26
+ "scripts": {
27
+ "build": "tsup src/index.ts --format esm,cjs --dts",
28
+ "dev": "tsup src/index.ts --format esm,cjs --dts --watch",
29
+ "test": "jest --passWithNoTests",
30
+ "clean": "rm -rf dist"
31
+ },
32
+ "dependencies": {
33
+ "@leanmcp/core": "^0.3.1",
34
+ "@leanmcp/auth": "^0.3.1",
35
+ "@leanmcp/ui": "^0.1.0",
36
+ "@leanmcp/utils": "^0.1.0",
37
+ "@leanmcp/elicitation": "^0.1.0",
38
+ "@leanmcp/env-injection": "^0.1.0"
39
+ },
40
+ "devDependencies": {
41
+ "@leanmcp/cli": "^0.2.1"
42
+ },
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "git+https://github.com/LeanMCP/leanmcp-sdk.git",
46
+ "directory": "packages/leanmcp"
47
+ },
48
+ "homepage": "https://github.com/LeanMCP/leanmcp-sdk#readme",
49
+ "bugs": {
50
+ "url": "https://github.com/LeanMCP/leanmcp-sdk/issues"
51
+ },
52
+ "keywords": [
53
+ "mcp",
54
+ "model-context-protocol",
55
+ "typescript",
56
+ "decorators",
57
+ "server",
58
+ "runtime",
59
+ "sdk",
60
+ "authentication",
61
+ "ui",
62
+ "react"
63
+ ],
64
+ "author": "LeanMCP <admin@leanmcp.com>",
65
+ "license": "MIT",
66
+ "publishConfig": {
67
+ "access": "public"
68
+ }
69
+ }