@leanmcp/core 0.4.7-alpha.34.1a4db16 → 0.4.7-alpha.36.dac94a7

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 (2) hide show
  1. package/README.md +138 -23
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ # @leanmcp/core
2
+
1
3
  <p align="center">
2
4
  <img
3
5
  src="https://raw.githubusercontent.com/LeanMCP/leanmcp-sdk/refs/heads/main/assets/logo.png"
@@ -6,11 +8,6 @@
6
8
  />
7
9
  </p>
8
10
 
9
- <p align="center">
10
- <strong>@leanmcp/core</strong><br/>
11
- Core library for building MCP servers with TypeScript decorators and declarative schema definition.
12
- </p>
13
-
14
11
  <p align="center">
15
12
  <a href="https://www.npmjs.com/package/@leanmcp/core">
16
13
  <img src="https://img.shields.io/npm/v/@leanmcp/core" alt="npm version" />
@@ -22,7 +19,7 @@
22
19
  <img src="https://img.shields.io/badge/Docs-leanmcp-0A66C2?" />
23
20
  </a>
24
21
  <a href="https://discord.com/invite/DsRcA3GwPy">
25
- <img src="https://img.shields.io/badge/Discord-Join-5865F2?logo=discord&logoColor=white" />
22
+ <img src="https://dcbadge.limes.pink/api/server/DsRcA3GwPy?style=flat" alt="Discord" />
26
23
  </a>
27
24
  <a href="https://x.com/LeanMcp">
28
25
  <img src="https://img.shields.io/badge/@LeanMCP-f5f5f5?logo=x&logoColor=000000" />
@@ -33,15 +30,48 @@
33
30
  <a href="https://deepwiki.com/LeanMCP/leanmcp-sdk"><img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki"></a>
34
31
  </p>
35
32
 
36
- ## Features
33
+ ```json
34
+ {
35
+ "package": "@leanmcp/core",
36
+ "purpose": "Core TypeScript framework for building MCP servers with decorators",
37
+ "useCases": [
38
+ "MCP server development",
39
+ "Type-safe tool definitions",
40
+ "HTTP transport",
41
+ "Schema validation"
42
+ ],
43
+ "dependencies": ["@modelcontextprotocol/sdk"],
44
+ "exports": ["@Tool", "@Prompt", "@Resource", "@SchemaConstraint", "createHTTPServer", "MCPServer"]
45
+ }
46
+ ```
37
47
 
38
- - **Type-Safe Decorators** — `@Tool`, `@Prompt`, `@Resource` with full TypeScript support
39
- - **Auto-Discovery** — Zero-config service discovery from `./mcp` directory
40
- - **Schema Generation** Declarative JSON Schema with `@SchemaConstraint` decorators
41
- - **HTTP Transport** — Production-ready HTTP server with session management
42
- - **Input Validation** — Built-in AJV validation for all inputs
43
- - **Structured Content** Automatic `structuredContent` for ChatGPT Apps SDK compatibility
44
- - **MCP Compliant** Built on official `@modelcontextprotocol/sdk`
48
+ ## Overview
49
+
50
+ - **What it is**: Core TypeScript framework for building Model Context Protocol (MCP) servers using decorators and automatic schema validation
51
+ - **Purpose**: Provides type-safe decorators (`@Tool`, `@Prompt`, `@Resource`) with HTTP transport and zero-config service discovery
52
+ - **Key benefits**:
53
+ - Type-safe decorators with full TypeScript support
54
+ - Automatic JSON Schema generation from TypeScript classes
55
+ - Production-ready HTTP server with session management
56
+ - Zero-config auto-discovery from `./mcp` directory
57
+ - Built-in input validation with AJV
58
+
59
+ ## When to Use It
60
+
61
+ **Use `@leanmcp/core` when:**
62
+
63
+ - Building any MCP server (this is the foundation package)
64
+ - You want type safety and decorator-based development
65
+ - Need HTTP transport for production deployment
66
+ - Require automatic schema validation and generation
67
+ - Want zero-config service discovery
68
+
69
+ **You probably do NOT need this if:**
70
+
71
+ - Building MCP clients (use `@modelcontextprotocol/sdk` directly)
72
+ - Creating simple scripts without HTTP servers
73
+ - Working in non-TypeScript environments
74
+ - Only need basic MCP protocol without decorators
45
75
 
46
76
  ## Installation
47
77
 
@@ -55,8 +85,60 @@ For HTTP server support:
55
85
  npm install express cors
56
86
  ```
57
87
 
88
+ **Required TypeScript configuration:**
89
+
90
+ ```json
91
+ {
92
+ "compilerOptions": {
93
+ "experimentalDecorators": true,
94
+ "emitDecoratorMetadata": true
95
+ }
96
+ }
97
+ ```
98
+
58
99
  ## Quick Start
59
100
 
101
+ ```typescript
102
+ import { createHTTPServer, Tool, SchemaConstraint } from '@leanmcp/core';
103
+
104
+ class GreetInput {
105
+ @SchemaConstraint({
106
+ description: 'Name to greet',
107
+ minLength: 1,
108
+ })
109
+ name!: string;
110
+ }
111
+
112
+ export class GreetingService {
113
+ @Tool({
114
+ description: 'Greet someone',
115
+ inputClass: GreetInput,
116
+ })
117
+ async greet(input: GreetInput) {
118
+ return { message: `Hello, ${input.name}!` };
119
+ }
120
+ }
121
+
122
+ // Auto-discovers services from ./mcp directory
123
+ await createHTTPServer({
124
+ name: 'my-mcp-server',
125
+ version: '1.0.0',
126
+ port: 3001,
127
+ });
128
+ ```
129
+
130
+ ## Key Features
131
+
132
+ - **Type-Safe Decorators** — `@Tool`, `@Prompt`, `@Resource` with full TypeScript support
133
+ - **Auto-Discovery** — Zero-config service discovery from `./mcp` directory
134
+ - **Schema Generation** — Declarative JSON Schema with `@SchemaConstraint` decorators
135
+ - **HTTP Transport** — Production-ready HTTP server with session management
136
+ - **Input Validation** — Built-in AJV validation for all inputs
137
+ - **Structured Content** — Automatic `structuredContent` for ChatGPT Apps SDK compatibility
138
+ - **MCP Compliant** — Built on official `@modelcontextprotocol/sdk`
139
+
140
+ ## Usage / Examples
141
+
60
142
  ### Zero-Config (Recommended)
61
143
 
62
144
  The simplest way to create an MCP server with auto-discovery:
@@ -126,7 +208,9 @@ export class SentimentService {
126
208
 
127
209
  ---
128
210
 
129
- ## Decorators
211
+ ## API Reference
212
+
213
+ ### Core Decorators
130
214
 
131
215
  ### @Tool
132
216
 
@@ -322,7 +406,38 @@ server.getServer(); // Get underlying MCP SDK server
322
406
 
323
407
  ---
324
408
 
325
- ## Auto-Discovery
409
+ ## Integration with Other LeanMCP Packages
410
+
411
+ **@leanmcp/core** is the foundation package that all other LeanMCP packages build upon:
412
+
413
+ - **[@leanmcp/auth](https://www.npmjs.com/package/@leanmcp/auth)** — Add authentication decorators to protect tools
414
+ - **[@leanmcp/ui](https://www.npmjs.com/package/@leanmcp/ui)** — Build interactive MCP apps with React components
415
+ - **[@leanmcp/elicitation](https://www.npmjs.com/package/@leanmcp/elicitation)** — Collect structured user input during tool execution
416
+ - **[@leanmcp/env-injection](https://www.npmjs.com/package/@leanmcp/env-injection)** — Request-scoped environment variables for user secrets
417
+ - **[@leanmcp/utils](https://www.npmjs.com/package/@leanmcp/utils)** — Utility functions for response formatting and retry logic
418
+
419
+ **Example integration:**
420
+
421
+ ```typescript
422
+ import { Tool } from '@leanmcp/core';
423
+ import { Authenticated } from '@leanmcp/auth';
424
+ import { Elicitation } from '@leanmcp/elicitation';
425
+
426
+ @Authenticated(authProvider)
427
+ export class SecureService {
428
+ @Tool({ description: 'Protected tool with user input' })
429
+ @Elicitation({ fields: [{ name: 'data', type: 'text', required: true }] })
430
+ async protectedTool(input: { data: string }) {
431
+ return { result: input.data };
432
+ }
433
+ }
434
+ ```
435
+
436
+ ---
437
+
438
+ ## Best Practices / Troubleshooting
439
+
440
+ ### Auto-Discovery
326
441
 
327
442
  Services are automatically discovered from the `./mcp` directory:
328
443
 
@@ -474,12 +589,12 @@ async myTool(input: MyInput): Promise<{ result: string }> {
474
589
  - [@leanmcp/ui](https://www.npmjs.com/package/@leanmcp/ui) — MCP App UI components
475
590
  - [@leanmcp/elicitation](https://www.npmjs.com/package/@leanmcp/elicitation) — Structured user input
476
591
 
477
- ## Links
478
-
479
- - [GitHub Repository](https://github.com/LeanMCP/leanmcp-sdk)
480
- - [NPM Package](https://www.npmjs.com/package/@leanmcp/core)
481
- - [MCP Specification](https://spec.modelcontextprotocol.io/)
592
+ ---
482
593
 
483
- ## License
594
+ ## Links
484
595
 
485
- MIT
596
+ - **Documentation**: [https://docs.leanmcp.com/sdk/core](https://docs.leanmcp.com/sdk/core)
597
+ - **GitHub**: [https://github.com/LeanMCP/leanmcp-sdk/tree/main/packages/core](https://github.com/LeanMCP/leanmcp-sdk/tree/main/packages/core)
598
+ - **npm**: [https://www.npmjs.com/package/@leanmcp/core](https://www.npmjs.com/package/@leanmcp/core)
599
+ - **MCP Specification**: [https://spec.modelcontextprotocol.io/](https://spec.modelcontextprotocol.io/)
600
+ - **License**: MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leanmcp/core",
3
- "version": "0.4.7-alpha.34.1a4db16",
3
+ "version": "0.4.7-alpha.36.dac94a7",
4
4
  "description": "Core library implementing decorators, reflection, and MCP runtime server",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",