fa-mcp-sdk 0.2.249 → 0.2.258

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 (46) hide show
  1. package/cli-template/FA-MCP-SDK-DOC/00-FA-MCP-SDK-index.md +45 -161
  2. package/cli-template/FA-MCP-SDK-DOC/01-getting-started.md +71 -226
  3. package/cli-template/FA-MCP-SDK-DOC/02-1-tools-and-api.md +80 -360
  4. package/cli-template/FA-MCP-SDK-DOC/02-2-prompts-and-resources.md +191 -342
  5. package/cli-template/FA-MCP-SDK-DOC/03-configuration.md +141 -279
  6. package/cli-template/FA-MCP-SDK-DOC/04-authentication.md +73 -522
  7. package/cli-template/FA-MCP-SDK-DOC/05-ad-authorization.md +68 -419
  8. package/cli-template/FA-MCP-SDK-DOC/06-utilities.md +64 -447
  9. package/cli-template/FA-MCP-SDK-DOC/07-testing-and-operations.md +39 -196
  10. package/cli-template/package.json +2 -1
  11. package/config/local.yaml +1 -1
  12. package/dist/core/_types_/types.d.ts +36 -10
  13. package/dist/core/_types_/types.d.ts.map +1 -1
  14. package/dist/core/auth/admin-auth.js +1 -1
  15. package/dist/core/auth/admin-auth.js.map +1 -1
  16. package/dist/core/auth/middleware.js +8 -8
  17. package/dist/core/auth/middleware.js.map +1 -1
  18. package/dist/core/auth/multi-auth.d.ts.map +1 -1
  19. package/dist/core/auth/multi-auth.js +15 -14
  20. package/dist/core/auth/multi-auth.js.map +1 -1
  21. package/dist/core/index.d.ts +1 -1
  22. package/dist/core/index.d.ts.map +1 -1
  23. package/dist/core/index.js.map +1 -1
  24. package/dist/core/mcp/create-mcp-server.js +8 -9
  25. package/dist/core/mcp/create-mcp-server.js.map +1 -1
  26. package/dist/core/mcp/prompts.d.ts +10 -5
  27. package/dist/core/mcp/prompts.d.ts.map +1 -1
  28. package/dist/core/mcp/prompts.js +17 -15
  29. package/dist/core/mcp/prompts.js.map +1 -1
  30. package/dist/core/mcp/resources.d.ts +4 -4
  31. package/dist/core/mcp/resources.d.ts.map +1 -1
  32. package/dist/core/mcp/resources.js +21 -20
  33. package/dist/core/mcp/resources.js.map +1 -1
  34. package/dist/core/utils/utils.d.ts +2 -1
  35. package/dist/core/utils/utils.d.ts.map +1 -1
  36. package/dist/core/utils/utils.js +2 -2
  37. package/dist/core/utils/utils.js.map +1 -1
  38. package/dist/core/web/home-api.d.ts.map +1 -1
  39. package/dist/core/web/home-api.js +4 -3
  40. package/dist/core/web/home-api.js.map +1 -1
  41. package/dist/core/web/server-http.d.ts.map +1 -1
  42. package/dist/core/web/server-http.js +36 -21
  43. package/dist/core/web/server-http.js.map +1 -1
  44. package/package.json +1 -1
  45. package/scripts/update-doc.js +21 -0
  46. package/src/template/start.ts +1 -1
@@ -1,50 +1,6 @@
1
1
  # FA-MCP-SDK Documentation Index
2
2
 
3
- ## Overview
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
7
- sections based on your task.
8
-
9
- ## Using with Claude Code
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
13
- follows SDK patterns.
14
-
15
- ### Example Prompts
16
-
17
- **Creating tools:**
18
- ```
19
- Use the fa-mcp-sdk subagent to add a tool "get_user" that fetches user data by ID from the database
20
- ```
21
-
22
- **Adding REST API:**
23
- ```
24
- Use the fa-mcp-sdk subagent to create REST endpoint POST /api/users for user registration with validation
25
- ```
26
-
27
- **Setting up authentication:**
28
- ```
29
- Use the fa-mcp-sdk subagent to configure JWT authentication with 1 hour token expiration
30
- ```
31
-
32
- **Database integration:**
33
- ```
34
- Use the fa-mcp-sdk subagent to add PostgreSQL integration and create a tool to query orders table
35
- ```
36
-
37
- **Complex tasks:**
38
- ```
39
- Use the fa-mcp-sdk subagent to create an MCP server for managing TODO lists with:
40
- - tools: add_todo, list_todos, complete_todo, delete_todo
41
- - PostgreSQL storage
42
- - JWT authentication
43
- - REST API for web client
44
- ```
45
-
46
- The agent will read the appropriate documentation files and implement the
47
- functionality following SDK conventions.
3
+ TypeScript framework for building MCP servers.
48
4
 
49
5
  ## Quick Start
50
6
 
@@ -54,104 +10,43 @@ npm install fa-mcp-sdk
54
10
 
55
11
  ## Documentation Structure
56
12
 
57
- | File | Content | Read When |
58
- |----------------------------------------------------------------|---------|-----------|
59
- | [01-getting-started.md](01-getting-started.md) | Installation, project structure, `initMcpServer()`, core types (`McpServerData`, `IPromptData`, `IResourceData`), Configuration API (`AppConfig`, `getProjectData`, `getSafeAppConfig`) | 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 (`configureOpenAPI`, `OpenAPISpecResponse`, `SwaggerUIConfig`) | Creating MCP tools, adding REST endpoints, configuring Swagger |
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 (`TTokenType`), Basic auth, server tokens, custom validators, `createAuthMW()`, Token Generator (`generateTokenApp`) | Setting up authentication, generating tokens |
64
- | [05-ad-authorization.md](05-ad-authorization.md) | AD configuration types (`IADConfig`, `IDcConfig`), AD group-based authorization examples: HTTP level, all tools, per-tool | Implementing AD group restrictions |
65
- | [06-utilities.md](06-utilities.md) | Error handling (`ServerError`), utility functions (`normalizeHeaders`, `getTools`), constants (`ROOT_PROJECT_DIR`), logging, events, Consul integration, graceful shutdown | Error handling, logging, service discovery |
66
- | [07-testing-and-operations.md](07-testing-and-operations.md) | Test clients (STDIO, HTTP, SSE, Streamable HTTP - `McpStreamableHttpClient`), transport types, best practices | Testing, deployment, operations |
67
-
68
- ## Common Tasks Quick Reference
69
-
70
- ### Create a new MCP server
71
- Read: `01-getting-started.md` → `02-1-tools-and-api.md`
72
-
73
- ### Add MCP tools
74
- Read: `02-1-tools-and-api.md` (Tool Development section)
75
-
76
- ### Add REST API endpoints
77
- Read: `02-1-tools-and-api.md` (REST API Endpoints section)
78
- - Use tsoa decorators (`@Route`, `@Get`, `@Post`, `@Tags`)
79
- - Swagger generates automatically if `swagger/openapi.yaml` doesn't exist
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
-
93
- ### Configure authentication
94
- Read: `04-authentication.md`
95
- - Enable in `config/default.yaml` under `webServer.auth`
96
- - Options: `permanentServerTokens`, `jwtToken`, `basic`, custom validator
97
-
98
- ### Add AD group authorization
99
- Read: `05-ad-authorization.md`
100
- - HTTP level (block at entry)
101
- - Tool level (restrict all or specific tools)
102
-
103
- ### Use database
104
- Read: `03-configuration.md` (Database Integration section)
105
- - Set `db.postgres.dbs.main.host` in config
106
- - Use `queryMAIN()`, `execMAIN()`, `oneRowMAIN()`
107
-
108
- ### Use caching
109
- Read: `03-configuration.md` (Cache Management section)
110
- - `getCache()` → `cache.get()`, `cache.set()`, `cache.getOrSet()`
111
-
112
- ### Write tests
113
- Read: `07-testing-and-operations.md`
114
- - Use `McpHttpClient`, `McpStdioClient`, `McpSseClient`
115
- - Use `getAuthHeadersForTests()` for auth headers
116
-
117
- ## Key Exports from fa-mcp-sdk
13
+ | File | Content | Read When |
14
+ |------|---------|-----------|
15
+ | [01-getting-started](01-getting-started.md) | `initMcpServer()`, `McpServerData`, `IPromptData`, `IResourceData`, `AppConfig` | Starting new project |
16
+ | [02-1-tools-and-api](02-1-tools-and-api.md) | Tool definitions, `toolHandler`, REST API with tsoa, OpenAPI/Swagger | Creating tools, REST endpoints |
17
+ | [02-2-prompts-and-resources](02-2-prompts-and-resources.md) | Standard/custom prompts, resources, `requireAuth` | Configuring prompts/resources |
18
+ | [03-configuration](03-configuration.md) | `appConfig`, YAML config, cache, PostgreSQL | Server configuration, DB |
19
+ | [04-authentication](04-authentication.md) | JWT, Basic auth, server tokens, `createAuthMW()`, Token Generator | Authentication setup |
20
+ | [05-ad-authorization](05-ad-authorization.md) | AD group authorization at HTTP/tool levels | AD group restrictions |
21
+ | [06-utilities](06-utilities.md) | `ServerError`, `normalizeHeaders`, logging, Consul, graceful shutdown | Error handling, utilities |
22
+ | [07-testing-and-operations](07-testing-and-operations.md) | Test clients (STDIO, HTTP, SSE, Streamable HTTP) | Testing, deployment |
118
23
 
119
- ```typescript
120
- // Initialization
121
- import { initMcpServer, McpServerData } from 'fa-mcp-sdk';
24
+ ## Key Exports
122
25
 
123
- // Configuration
124
- import { appConfig, AppConfig, getProjectData, getSafeAppConfig, ROOT_PROJECT_DIR } from 'fa-mcp-sdk';
26
+ ```typescript
27
+ // Core
28
+ import { initMcpServer, McpServerData, appConfig, getProjectData, getSafeAppConfig, ROOT_PROJECT_DIR } from 'fa-mcp-sdk';
125
29
 
126
- // Authentication
30
+ // Auth
127
31
  import { createAuthMW, generateToken, getAuthHeadersForTests, TTokenType, generateTokenApp } from 'fa-mcp-sdk';
128
32
 
129
- // Tools
130
- import { formatToolResult, ToolExecutionError, getTools } from 'fa-mcp-sdk';
131
-
132
- // Errors
133
- import { ServerError, BaseMcpError, ValidationError } from 'fa-mcp-sdk';
134
-
135
- // Database
136
- import { queryMAIN, execMAIN, oneRowMAIN, checkMainDB } from 'fa-mcp-sdk';
33
+ // Tools & Errors
34
+ import { formatToolResult, ToolExecutionError, ServerError, BaseMcpError, ValidationError, getTools } from 'fa-mcp-sdk';
137
35
 
138
- // Cache
139
- import { getCache } from 'fa-mcp-sdk';
140
-
141
- // Logging
142
- import { logger, fileLogger } from 'fa-mcp-sdk';
36
+ // Database & Cache
37
+ import { queryMAIN, execMAIN, oneRowMAIN, checkMainDB, getCache } from 'fa-mcp-sdk';
143
38
 
144
39
  // Utilities
145
- import { trim, ppj, toError, toStr, normalizeHeaders } from 'fa-mcp-sdk';
40
+ import { logger, fileLogger, trim, ppj, toError, toStr, normalizeHeaders } from 'fa-mcp-sdk';
146
41
 
147
- // Test clients
42
+ // Test Clients
148
43
  import { McpHttpClient, McpStdioClient, McpSseClient, McpStreamableHttpClient } from 'fa-mcp-sdk';
149
44
 
150
45
  // AD Groups
151
46
  import { initADGroupChecker, IADConfig, IDcConfig } from 'fa-mcp-sdk';
152
47
 
153
- // OpenAPI/Swagger
154
- import { configureOpenAPI, createSwaggerUIAssetsMiddleware, OpenAPISpecResponse, SwaggerUIConfig } from 'fa-mcp-sdk';
48
+ // OpenAPI
49
+ import { configureOpenAPI, OpenAPISpecResponse, SwaggerUIConfig } from 'fa-mcp-sdk';
155
50
  ```
156
51
 
157
52
  ## Project Structure
@@ -159,33 +54,27 @@ import { configureOpenAPI, createSwaggerUIAssetsMiddleware, OpenAPISpecResponse,
159
54
  ```
160
55
  my-mcp-server/
161
56
  ├── config/
162
- │ ├── default.yaml # Base configuration
163
- │ ├── development.yaml # Development overrides
164
- │ ├── local.yaml # Local secrets (gitignored)
165
- │ └── production.yaml # Production overrides
57
+ │ ├── default.yaml # Base configuration
58
+ │ ├── development.yaml # Dev overrides
59
+ │ ├── local.yaml # Local secrets (gitignored)
60
+ │ └── production.yaml # Prod overrides
166
61
  ├── src/
167
62
  │ ├── _types_/
168
- │ │ ├── common.d.ts # Common type declarations
169
- │ │ └── custom-config.ts # Custom config interface
63
+ │ │ └── custom-config.ts # Custom config interface
170
64
  │ ├── api/
171
- │ │ └── router.ts # REST endpoints with tsoa decorators
172
- │ ├── asset/
173
- │ │ └── logo.svg # Static assets
65
+ │ │ └── router.ts # REST endpoints (tsoa)
174
66
  │ ├── prompts/
175
- │ │ ├── agent-brief.ts # Short agent description
176
- │ │ ├── agent-prompt.ts # Full agent system prompt
177
- │ │ └── custom-prompts.ts # Additional prompts
67
+ │ │ ├── agent-brief.ts # Short agent description
68
+ │ │ ├── agent-prompt.ts # Full agent prompt
69
+ │ │ └── custom-prompts.ts # Additional prompts
178
70
  │ ├── tools/
179
- │ │ ├── handle-tool-call.ts # Tool execution logic
180
- │ │ └── tools.ts # Tool definitions
181
- │ ├── custom-resources.ts # Custom MCP resources
182
- │ └── start.ts # Entry point
183
- ├── swagger/
184
- │ └── openapi.yaml # Auto-generated (gitignored)
71
+ │ │ ├── handle-tool-call.ts # Tool execution
72
+ │ │ └── tools.ts # Tool definitions
73
+ │ ├── custom-resources.ts # Custom MCP resources
74
+ │ └── start.ts # Entry point
185
75
  └── tests/
186
76
  ```
187
77
 
188
-
189
78
  ## Minimal Example
190
79
 
191
80
  **`src/start.ts`:**
@@ -208,19 +97,15 @@ await initMcpServer(serverData);
208
97
  ```typescript
209
98
  import { Tool } from '@modelcontextprotocol/sdk/types.js';
210
99
 
211
- export const tools: Tool[] = [
212
- {
213
- name: 'hello',
214
- description: 'Say hello',
215
- inputSchema: {
216
- type: 'object',
217
- properties: {
218
- name: { type: 'string', description: 'Name to greet' }
219
- },
220
- required: ['name']
221
- }
100
+ export const tools: Tool[] = [{
101
+ name: 'hello',
102
+ description: 'Say hello',
103
+ inputSchema: {
104
+ type: 'object',
105
+ properties: { name: { type: 'string', description: 'Name to greet' } },
106
+ required: ['name']
222
107
  }
223
- ];
108
+ }];
224
109
  ```
225
110
 
226
111
  **`src/tools/handle-tool-call.ts`:**
@@ -229,7 +114,6 @@ import { formatToolResult, ToolExecutionError } from 'fa-mcp-sdk';
229
114
 
230
115
  export const handleToolCall = async (params: { name: string; arguments?: any }): Promise<any> => {
231
116
  const { name, arguments: args } = params;
232
-
233
117
  switch (name) {
234
118
  case 'hello':
235
119
  return formatToolResult({ message: `Hello, ${args.name}!` });
@@ -1,295 +1,140 @@
1
- # Getting Started with FA-MCP-SDK
1
+ # Getting Started
2
2
 
3
- ## Overview
3
+ ## initMcpServer(data: McpServerData): Promise<void>
4
4
 
5
- The FA-MCP-SDK is a comprehensive TypeScript framework for building Model Context
6
- Protocol (MCP) servers. This documentation covers how to use the SDK
7
- to create your own MCP server project.
8
-
9
- ## Installation
10
-
11
- ```bash
12
- npm install fa-mcp-sdk
13
- ```
14
-
15
- ## Project Structure
16
-
17
- When creating a new MCP server, your project structure should follow this pattern:
18
-
19
- ```
20
- my-mcp-server/
21
- ├── config/ # Environment configurations
22
- │ ├── default.yaml # Base configuration
23
- │ ├── development.yaml # Development settings
24
- │ ├── production.yaml # Production settings
25
- │ └── test.yaml # Test environment
26
- ├── src/ # Source code
27
- │ ├── _types_/ # TypeScript type definitions
28
- │ ├── api/ # REST API routes (HTTP transport)
29
- │ │ └── router.ts # Express router with tsoa controllers
30
- │ ├── prompts/ # Agent prompts
31
- │ │ ├── agent-brief.ts # Agent brief
32
- │ │ ├── agent-prompt.ts # Main agent prompt
33
- │ │ └── custom-prompts.ts # Custom prompts
34
- │ ├── tools/ # MCP tool implementations
35
- │ │ ├── handle-tool-call.ts # Tool execution handler
36
- │ │ └── tools.ts # Tool definitions
37
- │ ├── custom-resources.ts # Custom MCP resources
38
- │ └── start.ts # Application entry point
39
- ├── tests/ # Test suites
40
- │ ├── mcp/ # MCP protocol tests
41
- │ └── utils.ts # Test utilities
42
- ├── .env # Environment variables
43
- ├── package.json # NPM package configuration
44
- └── tsconfig.json # TypeScript configuration
45
- ```
46
-
47
- ## Main Initialization Function
48
-
49
- ### `initMcpServer(data: McpServerData): Promise<void>`
50
-
51
- The primary function for starting your MCP server.
52
-
53
- **Example Usage in `src/start.ts`:**
5
+ Primary function for starting your MCP server.
54
6
 
55
7
  ```typescript
56
8
  import { initMcpServer, McpServerData, CustomAuthValidator } from 'fa-mcp-sdk';
57
9
  import { tools } from './tools/tools.js';
58
10
  import { handleToolCall } from './tools/handle-tool-call.js';
59
- import { AGENT_BRIEF } from './prompts/agent-brief.js';
60
- import { AGENT_PROMPT } from './prompts/agent-prompt.js';
61
-
62
- // Optional: Custom Authentication validator (black box function)
63
- const customAuthValidator: CustomAuthValidator = async (req): Promise<AuthResult> => {
64
- // Your custom authentication logic here - full request object available
65
- // Can access headers, IP, user-agent, etc.
66
- const authHeader = req.headers.authorization;
67
- const userID = req.headers['x-user-id'];
68
- const clientIP = req.headers['x-real-ip'] || req.connection?.remoteAddress;
69
-
70
- // Implement any authentication logic (database, LDAP, API, custom rules, etc.)
71
- const isAuthenticated = await authenticateRequest(req);
72
-
73
- if (isAuthenticated) {
74
- return {
75
- success: true,
76
- authType: 'basic',
77
- username: userID || 'unknown',
78
- };
79
- } else {
80
- return {
81
- success: false,
82
- error: 'Custom authentication failed',
83
- };
84
- }
85
- };
86
11
 
87
12
  const serverData: McpServerData = {
88
13
  tools,
89
14
  toolHandler: handleToolCall,
90
- agentBrief: AGENT_BRIEF,
91
- agentPrompt: AGENT_PROMPT,
92
-
93
- // Optional: Provide custom authentication function
94
- customAuthValidator: customAuthValidator,
95
-
96
- // ... other configuration
15
+ agentBrief: 'My agent description',
16
+ agentPrompt: 'Full agent instructions',
17
+ customAuthValidator: async (req) => { /* custom auth logic */ },
97
18
  };
98
19
 
99
20
  await initMcpServer(serverData);
100
21
  ```
101
22
 
102
- ## Core Types and Interfaces
103
-
104
- ### `McpServerData`
23
+ ## Core Types
105
24
 
106
- Main configuration interface for your MCP server.
25
+ ### McpServerData
107
26
 
108
27
  ```typescript
109
28
  interface McpServerData {
110
- // MCP Core Components
111
- tools: Tool[] | (() => Promise<Tool[]>); // Your tool definitions (static array or async function)
112
- toolHandler: (params: IToolHandlerParams) => Promise<any>; // Tool execution function
113
-
114
- // Agent Configuration
115
- agentBrief: string; // Brief description of your agent
116
- agentPrompt: string; // System prompt for your agent
117
- customPrompts?: IPromptData[]; // Additional custom prompts
118
-
119
- // Resources
120
- requiredHttpHeaders?: IRequiredHttpHeader[] | null; // HTTP headers for authentication
121
- customResources?: IResourceData[] | null; // Custom resource definitions
122
-
123
- // Authentication
124
- customAuthValidator?: CustomAuthValidator; // Custom authentication validator function
125
- tokenGenAuthHandler?: TokenGenAuthHandler; // Custom authorization for Token Generator admin page
126
-
127
- // HTTP Server Components (for HTTP transport)
128
- httpComponents?: {
129
- apiRouter?: Router | null; // Express router for additional endpoints
130
- };
131
-
132
- // UI Assets
133
- assets?: {
134
- logoSvg?: string; // SVG content for logo/favicon
135
- maintainerHtml?: string; // Support contact HTML snippet
136
- };
137
-
138
- // Consul Integration
139
- getConsulUIAddress?: (serviceId: string) => string; // Function to generate Consul UI URLs
29
+ tools: Tool[] | (() => Promise<Tool[]>); // Tool definitions
30
+ toolHandler: (params: IToolHandlerParams) => Promise<any>;
31
+ agentBrief: string; // Brief description
32
+ agentPrompt: string; // System prompt
33
+ customPrompts?: IPromptData[]; // Additional prompts
34
+ usedHttpHeaders?: IUsedHttpHeader[] | null; // HTTP headers for auth
35
+ customResources?: IResourceData[] | null; // Custom resources
36
+ customAuthValidator?: CustomAuthValidator; // Custom auth function
37
+ tokenGenAuthHandler?: TokenGenAuthHandler; // Token Generator auth
38
+ httpComponents?: { apiRouter?: Router | null }; // Express router
39
+ assets?: { logoSvg?: string; maintainerHtml?: string };
40
+ getConsulUIAddress?: (serviceId: string) => string;
140
41
  }
141
42
 
142
43
  interface IToolHandlerParams {
143
44
  name: string;
144
45
  arguments?: any;
145
46
  headers?: Record<string, string>;
146
- payload?: { user: string; [key: string]: any } | undefined; // JWT payload if authenticated
47
+ payload?: { user: string; [key: string]: any }; // JWT payload if authenticated
48
+ transport?: 'stdio' | 'sse' | 'http';
147
49
  }
148
50
  ```
149
51
 
150
- ### `IPromptData`
52
+ ### IPromptData
151
53
 
152
- Configuration for custom prompts in `src/prompts/custom-prompts.ts`.
54
+ For custom prompts in `src/prompts/custom-prompts.ts`:
153
55
 
154
56
  ```typescript
155
57
  interface IPromptData {
156
- name: string; // Unique prompt identifier
157
- description: string; // Human-readable description
158
- arguments: []; // Expected arguments (currently empty array)
159
- content: IPromptContent; // Static string or dynamic function
160
- requireAuth?: boolean; // Whether authentication is required
58
+ name: string;
59
+ description: string;
60
+ arguments: [];
61
+ content: string | ((request: IGetPromptRequest) => string | Promise<string>);
62
+ requireAuth?: boolean;
161
63
  }
162
64
 
163
- type IPromptContent = string | TPromptContentFunction;
164
- type TPromptContentFunction = (request: IGetPromptRequest) => string | Promise<string>;
65
+ // Example:
66
+ export const customPrompts: IPromptData[] = [{
67
+ name: 'custom_prompt',
68
+ description: 'A custom prompt',
69
+ arguments: [],
70
+ content: (request) => `Content with param: ${request.params.arguments?.sample}`,
71
+ }];
165
72
  ```
166
73
 
167
- Example `src/prompts/custom-prompts.ts`:
168
- ```typescript
169
- import { IPromptData } from 'fa-mcp-sdk';
74
+ ### IResourceData
170
75
 
171
- export const customPrompts: IPromptData[] = [
172
- {
173
- name: 'custom_prompt',
174
- description: 'A custom prompt for specific tasks',
175
- arguments: [],
176
- content: (request) => {
177
- const { sample } = request.params.arguments || {};
178
- return `Custom prompt content with parameter: ${sample}`;
179
- },
180
- },
181
- ];
182
- ```
183
-
184
- ### `IResourceData`
185
-
186
- Configuration for custom resources in `src/custom-resources.ts`.
76
+ For custom resources in `src/custom-resources.ts`:
187
77
 
188
78
  ```typescript
189
79
  interface IResourceData {
190
- uri: string; // Unique resource URI (e.g., "custom-resource://data1")
191
- name: string; // Resource name
192
- title?: string; // Optional display title
193
- description: string; // Human-readable description
194
- mimeType: string; // MIME type (e.g., "text/plain", "application/json")
195
- content: IResourceContent; // Static string, object, or dynamic function
196
- requireAuth?: boolean; // Whether authentication is required
80
+ uri: string; // e.g., "custom-resource://data1"
81
+ name: string;
82
+ title?: string;
83
+ description: string;
84
+ mimeType: string; // e.g., "text/plain", "application/json"
85
+ content: string | object | ((uri: string) => string | Promise<string>);
86
+ requireAuth?: boolean;
197
87
  }
198
88
 
199
- // Content types for resources
200
- type IResourceContent = string | object | TResourceContentFunction;
201
- type TResourceContentFunction = (uri: string) => string | Promise<string>;
202
- ```
203
-
204
- Example `src/custom-resources.ts`:
205
- ```typescript
206
- import { IResourceData } from 'fa-mcp-sdk';
207
-
208
- export const customResources: IResourceData[] = [
209
- {
210
- uri: 'custom-resource://resource1',
211
- name: 'resource1',
212
- description: 'Example resource with dynamic content',
213
- mimeType: 'text/plain',
214
- content: (uri) => {
215
- return `Dynamic content for ${uri} at ${new Date().toISOString()}`;
216
- },
217
- },
218
- ];
89
+ // Example:
90
+ export const customResources: IResourceData[] = [{
91
+ uri: 'custom-resource://resource1',
92
+ name: 'resource1',
93
+ description: 'Dynamic content example',
94
+ mimeType: 'text/plain',
95
+ content: (uri) => `Dynamic content for ${uri}`,
96
+ }];
219
97
  ```
220
98
 
221
- ---
222
-
223
99
  ## Configuration API
224
100
 
225
- ### `AppConfig`
101
+ ### appConfig
226
102
 
227
- Base configuration type for MCP server applications. Extends multiple configuration interfaces for database, logging, web server, MCP, and Active Directory settings.
103
+ Singleton with merged configuration from YAML files and environment variables:
228
104
 
229
105
  ```typescript
230
106
  import { appConfig, AppConfig } from 'fa-mcp-sdk';
231
107
 
232
- // appConfig is a singleton with merged configuration from:
233
- // - config/default.yaml (base)
234
- // - config/{NODE_ENV}.yaml (environment-specific)
235
- // - Environment variables (highest priority)
236
-
237
- // Access configuration values
238
108
  const port = appConfig.webServer.port;
239
109
  const serviceName = appConfig.name;
240
110
  const isAuthEnabled = appConfig.webServer.auth.enabled;
241
111
  ```
242
112
 
243
- **Key Properties:**
244
-
245
- | Property | Type | Description |
246
- |----------|------|-------------|
247
- | `name` | string | Package name from package.json |
248
- | `shortName` | string | Name without 'mcp' suffix |
249
- | `version` | string | Package version |
250
- | `description` | string | Package description |
251
- | `webServer` | object | HTTP server configuration (host, port, auth) |
252
- | `mcp` | object | MCP protocol settings (transportType, rateLimit) |
253
- | `logger` | object | Logging configuration (level, useFileLogger) |
254
- | `ad` | object | Active Directory configuration |
255
- | `consul` | object | Consul service discovery settings |
113
+ | Property | Description |
114
+ |----------|-------------|
115
+ | `name` | Package name from package.json |
116
+ | `shortName` | Name without 'mcp' suffix |
117
+ | `version` | Package version |
118
+ | `webServer` | HTTP server config (host, port, auth) |
119
+ | `mcp` | MCP settings (transportType, rateLimit) |
120
+ | `logger` | Logging config |
121
+ | `ad` | Active Directory config |
122
+ | `consul` | Service discovery settings |
256
123
 
257
- ### `getProjectData()`
124
+ ### getProjectData(): McpServerData
258
125
 
259
- Retrieves the MCP server project data that was passed to `initMcpServer()`.
126
+ Returns the data passed to `initMcpServer()`.
260
127
 
261
128
  ```typescript
262
- import { getProjectData, McpServerData } from 'fa-mcp-sdk';
263
-
264
- // Function Signature:
265
- function getProjectData(): McpServerData;
266
-
267
- // Example - Access project data from anywhere in your application:
268
129
  const projectData = getProjectData();
269
- console.log('Agent brief:', projectData.agentBrief);
270
- console.log('Tools count:', projectData.tools.length);
130
+ console.log(projectData.agentBrief, projectData.tools.length);
271
131
  ```
272
132
 
273
- ### `getSafeAppConfig()`
133
+ ### getSafeAppConfig(): any
274
134
 
275
- Returns a deep clone of the application configuration with sensitive data masked. Use this for logging configuration without exposing secrets.
135
+ Returns config clone with sensitive data masked. Use for logging:
276
136
 
277
137
  ```typescript
278
- import { getSafeAppConfig } from 'fa-mcp-sdk';
279
-
280
- // Function Signature:
281
- function getSafeAppConfig(): any;
282
-
283
- // Example - Log configuration safely:
284
138
  const safeConfig = getSafeAppConfig();
285
- console.log('Current configuration:', JSON.stringify(safeConfig, null, 2));
286
-
287
- // Sensitive values are masked:
288
- // - Database passwords: '[MASKED]'
289
- // - JWT keys, API tokens, etc.
139
+ console.log(JSON.stringify(safeConfig, null, 2)); // passwords masked
290
140
  ```
291
-
292
- **Typical Use Cases:**
293
- - Debugging configuration issues
294
- - Audit logging of startup parameters
295
- - Displaying configuration in admin interfaces