fa-mcp-sdk 0.2.217 → 0.2.218

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.
@@ -14,18 +14,19 @@ You are the FA-MCP-SDK Expert Agent, specialized in building Model Context Proto
14
14
 
15
15
  ## Documentation Map
16
16
 
17
- | User Task | Read These Files First |
18
- |-----------|------------------------|
19
- | Create new MCP server | `00-FA-MCP-SDK-index.md` → `01-getting-started.md` |
20
- | Add MCP tools | `02-tools-and-api.md` (Tool Development section) |
21
- | Add REST API endpoints | `02-tools-and-api.md` (REST API Endpoints section) |
22
- | Configure server | `03-configuration.md` |
23
- | Use database (PostgreSQL) | `03-configuration.md` (Database Integration section) |
24
- | Use caching | `03-configuration.md` (Cache Management section) |
25
- | Setup authentication | `04-authentication.md` |
26
- | Add AD group authorization | `05-ad-authorization.md` |
27
- | Error handling, logging | `06-utilities.md` |
28
- | Write tests | `07-testing-and-operations.md` |
17
+ | User Task | Read These Files First |
18
+ |----------------------------|-----------------------------------------------------------------|
19
+ | Create new MCP server | `00-FA-MCP-SDK-index.md` → `01-getting-started.md` |
20
+ | Add MCP tools | `02-1-tools-and-api.md` (Tool Development section) |
21
+ | Add REST API endpoints | `02-1-tools-and-api.md` (REST API Endpoints section) |
22
+ | Add required MCP prompts | `02-2-prompts-and-resources.md` (Prompts and resources section) |
23
+ | Configure server | `03-configuration.md` |
24
+ | Use database (PostgreSQL) | `03-configuration.md` (Database Integration section) |
25
+ | Use caching | `03-configuration.md` (Cache Management section) |
26
+ | Setup authentication | `04-authentication.md` |
27
+ | Add AD group authorization | `05-ad-authorization.md` |
28
+ | Error handling, logging | `06-utilities.md` |
29
+ | Write tests | `07-testing-and-operations.md` |
29
30
 
30
31
  ## Workflow
31
32
 
@@ -2,14 +2,14 @@
2
2
 
3
3
  ## Overview
4
4
 
5
- The FA-MCP-SDK is a comprehensive TypeScript framework for building Model Context
6
- Protocol (MCP) servers. This is the documentation index - read the relevant
5
+ The FA-MCP-SDK is a comprehensive TypeScript framework for building Model Context
6
+ Protocol (MCP) servers. This is the documentation index - read the relevant
7
7
  sections based on your task.
8
8
 
9
9
  ## Using with Claude Code
10
10
 
11
- This project includes a specialized agent `.claude/agents/fa-mcp-sdk.md` for
12
- Claude Code. The agent automatically reads relevant documentation sections and
11
+ This project includes a specialized agent `.claude/agents/fa-mcp-sdk.md` for
12
+ Claude Code. The agent automatically reads relevant documentation sections and
13
13
  follows SDK patterns.
14
14
 
15
15
  ### Example Prompts
@@ -43,7 +43,7 @@ Use the fa-mcp-sdk subagent to create an MCP server for managing TODO lists with
43
43
  - REST API for web client
44
44
  ```
45
45
 
46
- The agent will read the appropriate documentation files and implement the
46
+ The agent will read the appropriate documentation files and implement the
47
47
  functionality following SDK conventions.
48
48
 
49
49
  ## Quick Start
@@ -54,29 +54,42 @@ npm install fa-mcp-sdk
54
54
 
55
55
  ## Documentation Structure
56
56
 
57
- | File | Content | Read When |
58
- |------|---------|-----------|
59
- | [01-getting-started.md](01-getting-started.md) | Installation, project structure, `initMcpServer()`, core types (`McpServerData`, `IPromptData`, `IResourceData`) | Starting a new project, understanding project structure |
60
- | [02-tools-and-api.md](02-tools-and-api.md) | Tool definitions, `toolHandler`, HTTP headers, REST API with tsoa decorators, OpenAPI/Swagger auto-generation | Creating MCP tools, adding REST endpoints |
61
- | [03-configuration.md](03-configuration.md) | `appConfig`, YAML configuration, cache management, database integration (PostgreSQL) | Configuring the server, using cache or database |
62
- | [04-authentication.md](04-authentication.md) | Multi-auth system, JWT tokens, Basic auth, server tokens, custom validators, `createAuthMW()` | Setting up authentication |
63
- | [05-ad-authorization.md](05-ad-authorization.md) | AD group-based authorization examples: HTTP level, all tools, per-tool | Implementing AD group restrictions |
64
- | [06-utilities.md](06-utilities.md) | Error handling, utility functions, logging, events, Consul integration, graceful shutdown | Error handling, logging, service discovery |
57
+ | File | Content | Read When |
58
+ |------------------------------------------------------------|---------|-----------|
59
+ | [01-getting-started.md](01-getting-started.md) | Installation, project structure, `initMcpServer()`, core types (`McpServerData`, `IPromptData`, `IResourceData`) | Starting a new project, understanding project structure |
60
+ | [02-1-tools-and-api.md](02-1-tools-and-api.md) | Tool definitions, `toolHandler`, HTTP headers, REST API with tsoa decorators, OpenAPI/Swagger auto-generation | Creating MCP tools, adding REST endpoints |
61
+ | [02-2-prompts-and-resources.md](02-2-prompts-and-resources.md) | Standard prompts (agent-brief, agent-prompt), custom prompts, standard resources, custom resources, `requireAuth` | Configuring prompts and resources |
62
+ | [03-configuration.md](03-configuration.md) | `appConfig`, YAML configuration, cache management, database integration (PostgreSQL) | Configuring the server, using cache or database |
63
+ | [04-authentication.md](04-authentication.md) | Multi-auth system, JWT tokens, Basic auth, server tokens, custom validators, `createAuthMW()` | Setting up authentication |
64
+ | [05-ad-authorization.md](05-ad-authorization.md) | AD group-based authorization examples: HTTP level, all tools, per-tool | Implementing AD group restrictions |
65
+ | [06-utilities.md](06-utilities.md) | Error handling, utility functions, logging, events, Consul integration, graceful shutdown | Error handling, logging, service discovery |
65
66
  | [07-testing-and-operations.md](07-testing-and-operations.md) | Test clients (STDIO, HTTP, SSE), transport types, best practices | Testing, deployment, operations |
66
67
 
67
68
  ## Common Tasks Quick Reference
68
69
 
69
70
  ### Create a new MCP server
70
- Read: `01-getting-started.md` → `02-tools-and-api.md`
71
+ Read: `01-getting-started.md` → `02-1-tools-and-api.md`
71
72
 
72
73
  ### Add MCP tools
73
- Read: `02-tools-and-api.md` (Tool Development section)
74
+ Read: `02-1-tools-and-api.md` (Tool Development section)
74
75
 
75
76
  ### Add REST API endpoints
76
- Read: `02-tools-and-api.md` (REST API Endpoints section)
77
+ Read: `02-1-tools-and-api.md` (REST API Endpoints section)
77
78
  - Use tsoa decorators (`@Route`, `@Get`, `@Post`, `@Tags`)
78
79
  - Swagger generates automatically if `swagger/openapi.yaml` doesn't exist
79
80
 
81
+ ### Configure prompts
82
+ Read: `02-2-prompts-and-resources.md`
83
+ - Standard: `agent-brief.ts` (short description), `agent-prompt.ts` (full instructions)
84
+ - Custom: add to `customPrompts` array in `src/prompts/custom-prompts.ts`
85
+ - Use `requireAuth: true` to protect prompts
86
+
87
+ ### Configure resources
88
+ Read: `02-2-prompts-and-resources.md`
89
+ - Standard: `project://id`, `project://name`, `doc://readme`, `required://http-headers`
90
+ - Custom: add to `customResources` array in `src/custom-resources.ts`
91
+ - Use `requireAuth: true` to protect resources
92
+
80
93
  ### Configure authentication
81
94
  Read: `04-authentication.md`
82
95
  - Enable in `config/default.yaml` under `webServer.auth`
@@ -0,0 +1,342 @@
1
+ # Prompts and Resources
2
+
3
+ This document describes MCP prompts and resources provided by FA-MCP-SDK.
4
+
5
+ ## Prompts
6
+
7
+ Prompts are text instructions that LLM receives when working with your MCP server.
8
+ The SDK provides two standard prompts that must be configured for each new MCP server.
9
+
10
+ ### Standard Prompts
11
+
12
+ #### Agent Brief (`src/prompts/agent-brief.ts`)
13
+
14
+ **Level 1: Brief agent description**
15
+
16
+ This is a short description shown when LLM selects an agent from a list based on
17
+ user query. At this level, LLM doesn't see the list of tools — only the brief description.
18
+
19
+ ```typescript
20
+ /**
21
+ * Level 1: Brief agent description
22
+ * Used when LLM selects agents from a list based on user query
23
+ * LLM doesn't see tools at this level
24
+ */
25
+
26
+ export const AGENT_BRIEF = 'Your short agent description here';
27
+ ```
28
+
29
+ **Example:**
30
+ ```typescript
31
+ export const AGENT_BRIEF = 'Database management agent for PostgreSQL operations';
32
+ ```
33
+
34
+ #### Agent Prompt (`src/prompts/agent-prompt.ts`)
35
+
36
+ **Level 2: Full agent description**
37
+
38
+ This prompt becomes visible to the LLM after the agent router has selected this
39
+ agent from among others based on their short descriptions. At this point, the
40
+ LLM gains access to the full list of tools and this detailed prompt, which may
41
+ include instructions on how to call those tools.
42
+
43
+ In simple scenarios, this prompt can be very short or even empty if the tool descriptions alone are sufficient.
44
+
45
+ ```typescript
46
+ /**
47
+ * Level 2: Agent description
48
+ * This prompt becomes visible to the LLM after the agent router has selected
49
+ * this agent from among others based on their short descriptions.
50
+ * At that point, the LLM gains access to the full list of tools and this
51
+ * detailed prompt, which may include instructions on how to call those tools.
52
+ * In simple scenarios, this prompt can be very short or even empty if the
53
+ * tool descriptions alone are sufficient.
54
+ */
55
+
56
+ export const AGENT_PROMPT = `Your detailed agent instructions here.
57
+
58
+ Available tools:
59
+ - tool1: description
60
+ - tool2: description
61
+
62
+ Usage guidelines:
63
+ ...
64
+ `;
65
+ ```
66
+
67
+ **Example:**
68
+ ```typescript
69
+ export const AGENT_PROMPT = `You are a database management assistant for PostgreSQL.
70
+
71
+ Guidelines:
72
+ - Always check table existence before operations
73
+ - Use transactions for multi-step operations
74
+ - Return results in JSON format
75
+
76
+ Available tools will help you:
77
+ - Query data from tables
78
+ - Execute DDL/DML statements
79
+ - Manage database schema
80
+ `;
81
+ ```
82
+
83
+ ### Custom Prompts
84
+
85
+ You can add additional prompts in `src/prompts/custom-prompts.ts`. These prompts
86
+ are exposed via the MCP `prompts/list` and `prompts/get` endpoints.
87
+
88
+ #### Interface
89
+
90
+ ```typescript
91
+ interface IPromptData {
92
+ name: string; // Prompt identifier
93
+ description: string; // Description shown in prompts list
94
+ arguments: []; // Prompt arguments (currently empty array)
95
+ content: IPromptContent;// Static string or function returning content
96
+ requireAuth?: boolean; // If true, prompt requires authentication
97
+ }
98
+
99
+ type TPromptContentFunction = (request: IGetPromptRequest) => string | Promise<string>;
100
+ type IPromptContent = string | TPromptContentFunction;
101
+
102
+ interface IGetPromptRequest {
103
+ id?: string | number;
104
+ method: 'prompts/get' | 'prompts/content';
105
+ params: {
106
+ name: string;
107
+ arguments?: Record<string, string>;
108
+ };
109
+ }
110
+ ```
111
+
112
+ #### Example
113
+
114
+ ```typescript
115
+ import { IPromptData, IGetPromptRequest } from '../../core/index.js';
116
+
117
+ export const customPrompts: IPromptData[] = [
118
+ // Simple static prompt
119
+ {
120
+ name: 'greeting',
121
+ description: 'Standard greeting message',
122
+ arguments: [],
123
+ content: 'Hello! How can I help you today?',
124
+ },
125
+
126
+ // Dynamic prompt with function
127
+ {
128
+ name: 'context_prompt',
129
+ description: 'Context-aware prompt',
130
+ arguments: [],
131
+ content: (request: IGetPromptRequest) => {
132
+ const args = request.params.arguments || {};
133
+ return `Processing request with context: ${JSON.stringify(args)}`;
134
+ },
135
+ },
136
+
137
+ // Protected prompt requiring authentication
138
+ {
139
+ name: 'admin_instructions',
140
+ description: 'Administrative instructions',
141
+ arguments: [],
142
+ content: 'Admin-only instructions for system management...',
143
+ requireAuth: true, // Requires valid authentication
144
+ },
145
+ ];
146
+ ```
147
+
148
+ #### Connecting Custom Prompts
149
+
150
+ Pass custom prompts to `initMcpServer()` via `McpServerData`:
151
+
152
+ ```typescript
153
+ import { initMcpServer, McpServerData } from 'fa-mcp-sdk';
154
+ import { customPrompts } from './prompts/custom-prompts.js';
155
+
156
+ const serverData: McpServerData = {
157
+ tools,
158
+ toolHandler: handleToolCall,
159
+ agentBrief: AGENT_BRIEF,
160
+ agentPrompt: AGENT_PROMPT,
161
+ customPrompts, // Add custom prompts here
162
+ };
163
+
164
+ await initMcpServer(serverData);
165
+ ```
166
+
167
+ ---
168
+
169
+ ## Resources
170
+
171
+ Resources are data exposed via MCP `resources/list` and `resources/read` endpoints.
172
+ The SDK provides standard resources and supports custom resources.
173
+
174
+ ### Standard Resources
175
+
176
+ The SDK automatically provides the following resources:
177
+
178
+ | URI | Name | Description |
179
+ |---------------------------|------|-------------|
180
+ | `project://id` | project-id | Stable project identifier. Used for MCP server identification in registries and JWT authorization |
181
+ | `project://name` | product-name | Human-readable product name for UI display |
182
+ | `doc://readme` | README.md | Project documentation from README.md file. Used by RAG systems in MCP registries for search |
183
+ | `required://http-headers` | Required http headers | List of required HTTP headers (if configured via `requiredHttpHeaders`) |
184
+
185
+ **Resource content sources:**
186
+ - `project://id` → `appConfig.name` from configuration
187
+ - `project://name` → `appConfig.productName` from configuration
188
+ - `doc://readme` → `README.md` file from project root
189
+ - `required://http-headers` → `requiredHttpHeaders` array from `McpServerData`
190
+
191
+ ### Custom Resources
192
+
193
+ Add custom resources in `src/custom-resources.ts`.
194
+
195
+ #### Interface
196
+
197
+ ```typescript
198
+ interface IResourceInfo {
199
+ uri: string; // Resource URI (e.g., 'custom://my-resource')
200
+ name: string; // Resource name
201
+ title?: string; // Optional title
202
+ description: string; // Description shown in resources list
203
+ mimeType: string; // MIME type (e.g., 'text/plain', 'application/json')
204
+ requireAuth?: boolean; // If true, resource requires authentication
205
+ }
206
+
207
+ interface IResourceData extends IResourceInfo {
208
+ content: IResourceContent;
209
+ }
210
+
211
+ type TResourceContentFunction = (uri: string) => string | Promise<string>;
212
+ type IResourceContent = string | object | TResourceContentFunction;
213
+ ```
214
+
215
+ #### Example
216
+
217
+ ```typescript
218
+ import { IResourceData } from '../core/index.js';
219
+
220
+ export const customResources: IResourceData[] = [
221
+ // Simple static resource
222
+ {
223
+ uri: 'custom://config-info',
224
+ name: 'Configuration Info',
225
+ description: 'Server configuration summary',
226
+ mimeType: 'text/plain',
227
+ content: 'Server version: 1.0.0\nEnvironment: production',
228
+ },
229
+
230
+ // JSON resource
231
+ {
232
+ uri: 'custom://api-schema',
233
+ name: 'API Schema',
234
+ description: 'API schema definition',
235
+ mimeType: 'application/json',
236
+ content: {
237
+ version: '1.0',
238
+ endpoints: ['/api/users', '/api/orders'],
239
+ },
240
+ },
241
+
242
+ // Dynamic resource with async function
243
+ {
244
+ uri: 'custom://status',
245
+ name: 'Server Status',
246
+ description: 'Current server status',
247
+ mimeType: 'application/json',
248
+ content: async (uri: string) => {
249
+ const status = await getServerStatus();
250
+ return JSON.stringify(status);
251
+ },
252
+ },
253
+
254
+ // Protected resource requiring authentication
255
+ {
256
+ uri: 'custom://secrets',
257
+ name: 'Secret Configuration',
258
+ description: 'Protected configuration data',
259
+ mimeType: 'application/json',
260
+ content: { apiKeys: ['...'], credentials: {...} },
261
+ requireAuth: true, // Requires valid authentication
262
+ },
263
+ ];
264
+ ```
265
+
266
+ #### Connecting Custom Resources
267
+
268
+ Pass custom resources to `initMcpServer()` via `McpServerData`:
269
+
270
+ ```typescript
271
+ import { initMcpServer, McpServerData } from 'fa-mcp-sdk';
272
+ import { customResources } from './custom-resources.js';
273
+
274
+ const serverData: McpServerData = {
275
+ tools,
276
+ toolHandler: handleToolCall,
277
+ agentBrief: AGENT_BRIEF,
278
+ agentPrompt: AGENT_PROMPT,
279
+ customResources, // Add custom resources here
280
+ };
281
+
282
+ await initMcpServer(serverData);
283
+ ```
284
+
285
+ ### Required HTTP Headers
286
+
287
+ You can define required HTTP headers that clients must send when making requests:
288
+
289
+ ```typescript
290
+ interface IRequiredHttpHeader {
291
+ name: string; // Header name (e.g., "Authorization")
292
+ description: string; // Description (e.g., "JWT Token issued on request")
293
+ isOptional?: boolean; // If true, header is optional
294
+ }
295
+ ```
296
+
297
+ **Example:**
298
+ ```typescript
299
+ const serverData: McpServerData = {
300
+ tools,
301
+ toolHandler: handleToolCall,
302
+ agentBrief: AGENT_BRIEF,
303
+ agentPrompt: AGENT_PROMPT,
304
+ requiredHttpHeaders: [
305
+ {
306
+ name: 'Authorization',
307
+ description: 'JWT token in Bearer format',
308
+ },
309
+ {
310
+ name: 'X-Request-ID',
311
+ description: 'Optional request tracking ID',
312
+ isOptional: true,
313
+ },
314
+ ],
315
+ };
316
+ ```
317
+
318
+ When `requiredHttpHeaders` is configured, the resource `required://http-headers` becomes available with this information.
319
+
320
+ ---
321
+
322
+ ## Access Control with requireAuth
323
+
324
+ Both prompts and resources support the `requireAuth` property for access control:
325
+
326
+ ```typescript
327
+ {
328
+ // ... other properties
329
+ requireAuth: true, // Requires valid authentication
330
+ }
331
+ ```
332
+
333
+ When `requireAuth: true`:
334
+ - The prompt/resource is only accessible to authenticated users
335
+ - Unauthenticated requests receive an error
336
+ - Works with any authentication method configured in your server (JWT, Basic, NTLM, etc.)
337
+
338
+ **Use cases:**
339
+ - Sensitive configuration data
340
+ - Admin-only instructions
341
+ - Internal documentation
342
+ - API keys and credentials
@@ -47,7 +47,7 @@
47
47
  "dependencies": {
48
48
  "@modelcontextprotocol/sdk": "^1.25.2",
49
49
  "dotenv": "^17.2.3",
50
- "fa-mcp-sdk": "^0.2.217"
50
+ "fa-mcp-sdk": "^0.2.218"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/express": "^5.0.6",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fa-mcp-sdk",
3
3
  "productName": "FA MCP SDK",
4
- "version": "0.2.217",
4
+ "version": "0.2.218",
5
5
  "description": "Core infrastructure and templates for building Model Context Protocol (MCP) servers with TypeScript",
6
6
  "type": "module",
7
7
  "main": "dist/core/index.js",