@cyanheads/pubchem-mcp-server 1.0.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 +201 -0
- package/README.md +236 -0
- package/dist/config/index.d.ts +98 -0
- package/dist/config/index.js +326 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +214 -0
- package/dist/mcp-server/server.d.ts +21 -0
- package/dist/mcp-server/server.js +124 -0
- package/dist/mcp-server/tools/fetchAssaySummary/index.d.ts +7 -0
- package/dist/mcp-server/tools/fetchAssaySummary/index.js +7 -0
- package/dist/mcp-server/tools/fetchAssaySummary/logic.d.ts +71 -0
- package/dist/mcp-server/tools/fetchAssaySummary/logic.js +96 -0
- package/dist/mcp-server/tools/fetchAssaySummary/registration.d.ts +12 -0
- package/dist/mcp-server/tools/fetchAssaySummary/registration.js +68 -0
- package/dist/mcp-server/tools/fetchCompoundProperties/index.d.ts +7 -0
- package/dist/mcp-server/tools/fetchCompoundProperties/index.js +7 -0
- package/dist/mcp-server/tools/fetchCompoundProperties/logic.d.ts +131 -0
- package/dist/mcp-server/tools/fetchCompoundProperties/logic.js +100 -0
- package/dist/mcp-server/tools/fetchCompoundProperties/registration.d.ts +13 -0
- package/dist/mcp-server/tools/fetchCompoundProperties/registration.js +52 -0
- package/dist/mcp-server/tools/fetchCompoundXrefs/index.d.ts +7 -0
- package/dist/mcp-server/tools/fetchCompoundXrefs/index.js +7 -0
- package/dist/mcp-server/tools/fetchCompoundXrefs/logic.d.ts +89 -0
- package/dist/mcp-server/tools/fetchCompoundXrefs/logic.js +145 -0
- package/dist/mcp-server/tools/fetchCompoundXrefs/registration.d.ts +13 -0
- package/dist/mcp-server/tools/fetchCompoundXrefs/registration.js +52 -0
- package/dist/mcp-server/tools/fetchSubstanceDetails/index.d.ts +7 -0
- package/dist/mcp-server/tools/fetchSubstanceDetails/index.js +7 -0
- package/dist/mcp-server/tools/fetchSubstanceDetails/logic.d.ts +69 -0
- package/dist/mcp-server/tools/fetchSubstanceDetails/logic.js +97 -0
- package/dist/mcp-server/tools/fetchSubstanceDetails/registration.d.ts +13 -0
- package/dist/mcp-server/tools/fetchSubstanceDetails/registration.js +79 -0
- package/dist/mcp-server/tools/getCompoundImage/index.d.ts +7 -0
- package/dist/mcp-server/tools/getCompoundImage/index.js +7 -0
- package/dist/mcp-server/tools/getCompoundImage/logic.d.ts +42 -0
- package/dist/mcp-server/tools/getCompoundImage/logic.js +68 -0
- package/dist/mcp-server/tools/getCompoundImage/registration.d.ts +12 -0
- package/dist/mcp-server/tools/getCompoundImage/registration.js +57 -0
- package/dist/mcp-server/tools/searchAssaysByTarget/index.d.ts +7 -0
- package/dist/mcp-server/tools/searchAssaysByTarget/index.js +7 -0
- package/dist/mcp-server/tools/searchAssaysByTarget/logic.d.ts +35 -0
- package/dist/mcp-server/tools/searchAssaysByTarget/logic.js +64 -0
- package/dist/mcp-server/tools/searchAssaysByTarget/registration.d.ts +12 -0
- package/dist/mcp-server/tools/searchAssaysByTarget/registration.js +62 -0
- package/dist/mcp-server/tools/searchCompoundByIdentifier/index.d.ts +7 -0
- package/dist/mcp-server/tools/searchCompoundByIdentifier/index.js +7 -0
- package/dist/mcp-server/tools/searchCompoundByIdentifier/logic.d.ts +35 -0
- package/dist/mcp-server/tools/searchCompoundByIdentifier/logic.js +59 -0
- package/dist/mcp-server/tools/searchCompoundByIdentifier/registration.d.ts +12 -0
- package/dist/mcp-server/tools/searchCompoundByIdentifier/registration.js +51 -0
- package/dist/mcp-server/tools/searchCompoundsByFormula/index.d.ts +7 -0
- package/dist/mcp-server/tools/searchCompoundsByFormula/index.js +7 -0
- package/dist/mcp-server/tools/searchCompoundsByFormula/logic.d.ts +38 -0
- package/dist/mcp-server/tools/searchCompoundsByFormula/logic.js +75 -0
- package/dist/mcp-server/tools/searchCompoundsByFormula/registration.d.ts +12 -0
- package/dist/mcp-server/tools/searchCompoundsByFormula/registration.js +62 -0
- package/dist/mcp-server/tools/searchCompoundsBySimilarity/index.d.ts +7 -0
- package/dist/mcp-server/tools/searchCompoundsBySimilarity/index.js +7 -0
- package/dist/mcp-server/tools/searchCompoundsBySimilarity/logic.d.ts +41 -0
- package/dist/mcp-server/tools/searchCompoundsBySimilarity/logic.js +82 -0
- package/dist/mcp-server/tools/searchCompoundsBySimilarity/registration.d.ts +12 -0
- package/dist/mcp-server/tools/searchCompoundsBySimilarity/registration.js +62 -0
- package/dist/mcp-server/tools/searchCompoundsByStructure/index.d.ts +7 -0
- package/dist/mcp-server/tools/searchCompoundsByStructure/index.js +7 -0
- package/dist/mcp-server/tools/searchCompoundsByStructure/logic.d.ts +41 -0
- package/dist/mcp-server/tools/searchCompoundsByStructure/logic.js +78 -0
- package/dist/mcp-server/tools/searchCompoundsByStructure/registration.d.ts +13 -0
- package/dist/mcp-server/tools/searchCompoundsByStructure/registration.js +63 -0
- package/dist/mcp-server/transports/auth/core/authContext.d.ts +33 -0
- package/dist/mcp-server/transports/auth/core/authContext.js +24 -0
- package/dist/mcp-server/transports/auth/core/authTypes.d.ts +17 -0
- package/dist/mcp-server/transports/auth/core/authTypes.js +5 -0
- package/dist/mcp-server/transports/auth/core/authUtils.d.ts +18 -0
- package/dist/mcp-server/transports/auth/core/authUtils.js +45 -0
- package/dist/mcp-server/transports/auth/index.d.ts +10 -0
- package/dist/mcp-server/transports/auth/index.js +9 -0
- package/dist/mcp-server/transports/auth/strategies/jwt/jwtMiddleware.d.ts +27 -0
- package/dist/mcp-server/transports/auth/strategies/jwt/jwtMiddleware.js +149 -0
- package/dist/mcp-server/transports/auth/strategies/oauth/oauthMiddleware.d.ts +20 -0
- package/dist/mcp-server/transports/auth/strategies/oauth/oauthMiddleware.js +124 -0
- package/dist/mcp-server/transports/httpErrorHandler.d.ts +26 -0
- package/dist/mcp-server/transports/httpErrorHandler.js +73 -0
- package/dist/mcp-server/transports/httpTransport.d.ts +21 -0
- package/dist/mcp-server/transports/httpTransport.js +208 -0
- package/dist/mcp-server/transports/stdioTransport.d.ts +42 -0
- package/dist/mcp-server/transports/stdioTransport.js +63 -0
- package/dist/services/pubchem/pubchemApiClient.d.ts +52 -0
- package/dist/services/pubchem/pubchemApiClient.js +120 -0
- package/dist/types-global/errors.d.ts +127 -0
- package/dist/types-global/errors.js +126 -0
- package/dist/utils/index.d.ts +12 -0
- package/dist/utils/index.js +20 -0
- package/dist/utils/internal/errorHandler.d.ts +176 -0
- package/dist/utils/internal/errorHandler.js +335 -0
- package/dist/utils/internal/index.d.ts +9 -0
- package/dist/utils/internal/index.js +9 -0
- package/dist/utils/internal/logger.d.ts +148 -0
- package/dist/utils/internal/logger.js +430 -0
- package/dist/utils/internal/requestContext.d.ts +83 -0
- package/dist/utils/internal/requestContext.js +72 -0
- package/dist/utils/metrics/index.d.ts +7 -0
- package/dist/utils/metrics/index.js +7 -0
- package/dist/utils/metrics/tokenCounter.d.ts +35 -0
- package/dist/utils/metrics/tokenCounter.js +110 -0
- package/dist/utils/network/fetchWithTimeout.d.ts +21 -0
- package/dist/utils/network/fetchWithTimeout.js +59 -0
- package/dist/utils/network/index.d.ts +6 -0
- package/dist/utils/network/index.js +5 -0
- package/dist/utils/parsing/dateParser.d.ts +73 -0
- package/dist/utils/parsing/dateParser.js +107 -0
- package/dist/utils/parsing/index.d.ts +8 -0
- package/dist/utils/parsing/index.js +8 -0
- package/dist/utils/parsing/jsonParser.d.ts +82 -0
- package/dist/utils/parsing/jsonParser.js +126 -0
- package/dist/utils/scheduling/index.d.ts +6 -0
- package/dist/utils/scheduling/index.js +6 -0
- package/dist/utils/scheduling/scheduler.d.ts +72 -0
- package/dist/utils/scheduling/scheduler.js +152 -0
- package/dist/utils/security/idGenerator.d.ts +137 -0
- package/dist/utils/security/idGenerator.js +215 -0
- package/dist/utils/security/index.d.ts +9 -0
- package/dist/utils/security/index.js +9 -0
- package/dist/utils/security/rateLimiter.d.ts +108 -0
- package/dist/utils/security/rateLimiter.js +179 -0
- package/dist/utils/security/sanitization.d.ts +184 -0
- package/dist/utils/security/sanitization.js +453 -0
- package/package.json +108 -0
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Loads, validates, and exports application configuration.
|
|
3
|
+
* This module centralizes configuration management, sourcing values from
|
|
4
|
+
* environment variables and `package.json`. It uses Zod for schema validation
|
|
5
|
+
* to ensure type safety and correctness of configuration parameters.
|
|
6
|
+
*
|
|
7
|
+
* Key responsibilities:
|
|
8
|
+
* - Load environment variables from a `.env` file.
|
|
9
|
+
* - Read `package.json` for default server name and version.
|
|
10
|
+
* - Define a Zod schema for all expected environment variables.
|
|
11
|
+
* - Validate environment variables against the schema.
|
|
12
|
+
* - Construct and export a comprehensive `config` object.
|
|
13
|
+
* - Export individual configuration values like `logLevel` and `environment` for convenience.
|
|
14
|
+
*
|
|
15
|
+
* @module src/config/index
|
|
16
|
+
*/
|
|
17
|
+
import dotenv from "dotenv";
|
|
18
|
+
import { existsSync, mkdirSync, readFileSync, statSync } from "fs";
|
|
19
|
+
import path, { dirname, join } from "path";
|
|
20
|
+
import { fileURLToPath } from "url";
|
|
21
|
+
import { z } from "zod";
|
|
22
|
+
dotenv.config();
|
|
23
|
+
// --- Determine Project Root ---
|
|
24
|
+
/**
|
|
25
|
+
* Finds the project root directory by searching upwards for package.json.
|
|
26
|
+
* @param startDir The directory to start searching from.
|
|
27
|
+
* @returns The absolute path to the project root, or throws an error if not found.
|
|
28
|
+
*/
|
|
29
|
+
const findProjectRoot = (startDir) => {
|
|
30
|
+
let currentDir = startDir;
|
|
31
|
+
while (true) {
|
|
32
|
+
const packageJsonPath = join(currentDir, "package.json");
|
|
33
|
+
if (existsSync(packageJsonPath)) {
|
|
34
|
+
return currentDir;
|
|
35
|
+
}
|
|
36
|
+
const parentDir = dirname(currentDir);
|
|
37
|
+
if (parentDir === currentDir) {
|
|
38
|
+
// Reached the root of the filesystem without finding package.json
|
|
39
|
+
throw new Error(`Could not find project root (package.json) starting from ${startDir}`);
|
|
40
|
+
}
|
|
41
|
+
currentDir = parentDir;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
let projectRoot;
|
|
45
|
+
try {
|
|
46
|
+
// For ESM, __dirname is not available directly.
|
|
47
|
+
// import.meta.url gives the URL of the current module.
|
|
48
|
+
const currentModuleDir = dirname(fileURLToPath(import.meta.url));
|
|
49
|
+
projectRoot = findProjectRoot(currentModuleDir);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
console.error(`FATAL: Error determining project root: ${error.message}`);
|
|
53
|
+
// Fallback to process.cwd() if project root cannot be determined.
|
|
54
|
+
// This might happen in unusual execution environments.
|
|
55
|
+
projectRoot = process.cwd();
|
|
56
|
+
console.warn(`Warning: Using process.cwd() (${projectRoot}) as fallback project root.`);
|
|
57
|
+
}
|
|
58
|
+
// --- End Determine Project Root ---
|
|
59
|
+
const pkgPath = join(projectRoot, "package.json"); // Use determined projectRoot
|
|
60
|
+
let pkg = { name: "mcp-ts-template", version: "0.0.0" };
|
|
61
|
+
try {
|
|
62
|
+
pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
if (process.stdout.isTTY) {
|
|
66
|
+
console.error("Warning: Could not read package.json for default config values. Using hardcoded defaults.", error);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Zod schema for validating environment variables.
|
|
71
|
+
* Provides type safety, validation, defaults, and clear error messages.
|
|
72
|
+
* @private
|
|
73
|
+
*/
|
|
74
|
+
const EnvSchema = z.object({
|
|
75
|
+
/** Optional. The desired name for the MCP server. Defaults to `package.json` name. */
|
|
76
|
+
MCP_SERVER_NAME: z.string().optional(),
|
|
77
|
+
/** Optional. The version of the MCP server. Defaults to `package.json` version. */
|
|
78
|
+
MCP_SERVER_VERSION: z.string().optional(),
|
|
79
|
+
/** Minimum logging level. See `McpLogLevel` in logger utility. Default: "debug". */
|
|
80
|
+
MCP_LOG_LEVEL: z.string().default("debug"),
|
|
81
|
+
/** Directory for log files. Defaults to "logs" in project root. */
|
|
82
|
+
LOGS_DIR: z.string().default(path.join(projectRoot, "logs")),
|
|
83
|
+
/** Runtime environment (e.g., "development", "production"). Default: "development". */
|
|
84
|
+
NODE_ENV: z.string().default("development"),
|
|
85
|
+
/** MCP communication transport ("stdio" or "http"). Default: "stdio". */
|
|
86
|
+
MCP_TRANSPORT_TYPE: z.enum(["stdio", "http"]).default("stdio"),
|
|
87
|
+
/** HTTP server port (if MCP_TRANSPORT_TYPE is "http"). Default: 3010. */
|
|
88
|
+
MCP_HTTP_PORT: z.coerce.number().int().positive().default(3010),
|
|
89
|
+
/** HTTP server host (if MCP_TRANSPORT_TYPE is "http"). Default: "127.0.0.1". */
|
|
90
|
+
MCP_HTTP_HOST: z.string().default("127.0.0.1"),
|
|
91
|
+
/** Optional. Comma-separated allowed origins for CORS (HTTP transport). */
|
|
92
|
+
MCP_ALLOWED_ORIGINS: z.string().optional(),
|
|
93
|
+
/** Optional. Secret key (min 32 chars) for auth tokens (HTTP transport). CRITICAL for production. */
|
|
94
|
+
MCP_AUTH_SECRET_KEY: z
|
|
95
|
+
.string()
|
|
96
|
+
.min(32, "MCP_AUTH_SECRET_KEY must be at least 32 characters long for security reasons.")
|
|
97
|
+
.optional(),
|
|
98
|
+
/** The authentication mode to use. 'jwt' for internal simple JWTs, 'oauth' for OAuth 2.1. Default: 'jwt'. */
|
|
99
|
+
MCP_AUTH_MODE: z.enum(["jwt", "oauth"]).default("jwt"),
|
|
100
|
+
/** The expected issuer URL for OAuth 2.1 access tokens. CRITICAL for validation. */
|
|
101
|
+
OAUTH_ISSUER_URL: z.string().url().optional(),
|
|
102
|
+
/** The JWKS (JSON Web Key Set) URI for the OAuth 2.1 provider. If not provided, it's often discoverable from the issuer URL. */
|
|
103
|
+
OAUTH_JWKS_URI: z.string().url().optional(),
|
|
104
|
+
/** The audience claim for the OAuth 2.1 access tokens. This server will reject tokens not intended for it. */
|
|
105
|
+
OAUTH_AUDIENCE: z.string().optional(),
|
|
106
|
+
/** Optional. Application URL for OpenRouter integration. */
|
|
107
|
+
OPENROUTER_APP_URL: z
|
|
108
|
+
.string()
|
|
109
|
+
.url("OPENROUTER_APP_URL must be a valid URL (e.g., http://localhost:3000)")
|
|
110
|
+
.optional(),
|
|
111
|
+
/** Optional. Application name for OpenRouter. Defaults to MCP_SERVER_NAME or package name. */
|
|
112
|
+
OPENROUTER_APP_NAME: z.string().optional(),
|
|
113
|
+
/** Optional. API key for OpenRouter services. */
|
|
114
|
+
OPENROUTER_API_KEY: z.string().optional(),
|
|
115
|
+
/** Default LLM model. Default: "google/gemini-2.5-flash-preview-05-20". */
|
|
116
|
+
LLM_DEFAULT_MODEL: z
|
|
117
|
+
.string()
|
|
118
|
+
.default("google/gemini-2.5-flash-preview-05-20"),
|
|
119
|
+
/** Optional. Default LLM temperature (0.0-2.0). */
|
|
120
|
+
LLM_DEFAULT_TEMPERATURE: z.coerce.number().min(0).max(2).optional(),
|
|
121
|
+
/** Optional. Default LLM top_p (0.0-1.0). */
|
|
122
|
+
LLM_DEFAULT_TOP_P: z.coerce.number().min(0).max(1).optional(),
|
|
123
|
+
/** Optional. Default LLM max tokens (positive integer). */
|
|
124
|
+
LLM_DEFAULT_MAX_TOKENS: z.coerce.number().int().positive().optional(),
|
|
125
|
+
/** Optional. Default LLM top_k (non-negative integer). */
|
|
126
|
+
LLM_DEFAULT_TOP_K: z.coerce.number().int().nonnegative().optional(),
|
|
127
|
+
/** Optional. Default LLM min_p (0.0-1.0). */
|
|
128
|
+
LLM_DEFAULT_MIN_P: z.coerce.number().min(0).max(1).optional(),
|
|
129
|
+
/** Optional. OAuth provider authorization endpoint URL. */
|
|
130
|
+
OAUTH_PROXY_AUTHORIZATION_URL: z
|
|
131
|
+
.string()
|
|
132
|
+
.url("OAUTH_PROXY_AUTHORIZATION_URL must be a valid URL.")
|
|
133
|
+
.optional(),
|
|
134
|
+
/** Optional. OAuth provider token endpoint URL. */
|
|
135
|
+
OAUTH_PROXY_TOKEN_URL: z
|
|
136
|
+
.string()
|
|
137
|
+
.url("OAUTH_PROXY_TOKEN_URL must be a valid URL.")
|
|
138
|
+
.optional(),
|
|
139
|
+
/** Optional. OAuth provider revocation endpoint URL. */
|
|
140
|
+
OAUTH_PROXY_REVOCATION_URL: z
|
|
141
|
+
.string()
|
|
142
|
+
.url("OAUTH_PROXY_REVOCATION_URL must be a valid URL.")
|
|
143
|
+
.optional(),
|
|
144
|
+
/** Optional. OAuth provider issuer URL. */
|
|
145
|
+
OAUTH_PROXY_ISSUER_URL: z
|
|
146
|
+
.string()
|
|
147
|
+
.url("OAUTH_PROXY_ISSUER_URL must be a valid URL.")
|
|
148
|
+
.optional(),
|
|
149
|
+
/** Optional. OAuth service documentation URL. */
|
|
150
|
+
OAUTH_PROXY_SERVICE_DOCUMENTATION_URL: z
|
|
151
|
+
.string()
|
|
152
|
+
.url("OAUTH_PROXY_SERVICE_DOCUMENTATION_URL must be a valid URL.")
|
|
153
|
+
.optional(),
|
|
154
|
+
/** Optional. Comma-separated default OAuth client redirect URIs. */
|
|
155
|
+
OAUTH_PROXY_DEFAULT_CLIENT_REDIRECT_URIS: z.string().optional(),
|
|
156
|
+
/** Supabase Project URL. From `SUPABASE_URL`. */
|
|
157
|
+
SUPABASE_URL: z.string().url("SUPABASE_URL must be a valid URL.").optional(),
|
|
158
|
+
/** Supabase Anon Key (public). From `SUPABASE_ANON_KEY`. */
|
|
159
|
+
SUPABASE_ANON_KEY: z.string().optional(),
|
|
160
|
+
/** Supabase Service Role Key (secret). From `SUPABASE_SERVICE_ROLE_KEY`. */
|
|
161
|
+
SUPABASE_SERVICE_ROLE_KEY: z.string().optional(),
|
|
162
|
+
});
|
|
163
|
+
const parsedEnv = EnvSchema.safeParse(process.env);
|
|
164
|
+
if (!parsedEnv.success) {
|
|
165
|
+
if (process.stdout.isTTY) {
|
|
166
|
+
console.error("❌ Invalid environment variables found:", parsedEnv.error.flatten().fieldErrors);
|
|
167
|
+
}
|
|
168
|
+
// Consider throwing an error in production for critical misconfigurations.
|
|
169
|
+
}
|
|
170
|
+
const env = parsedEnv.success ? parsedEnv.data : EnvSchema.parse({});
|
|
171
|
+
// --- Directory Ensurance Function ---
|
|
172
|
+
/**
|
|
173
|
+
* Ensures a directory exists and is within the project root.
|
|
174
|
+
* @param dirPath The desired path for the directory (can be relative or absolute).
|
|
175
|
+
* @param rootDir The root directory of the project to contain the directory.
|
|
176
|
+
* @param dirName The name of the directory type for logging (e.g., "logs").
|
|
177
|
+
* @returns The validated, absolute path to the directory, or null if invalid.
|
|
178
|
+
*/
|
|
179
|
+
const ensureDirectory = (dirPath, rootDir, dirName) => {
|
|
180
|
+
const resolvedDirPath = path.isAbsolute(dirPath)
|
|
181
|
+
? dirPath
|
|
182
|
+
: path.resolve(rootDir, dirPath);
|
|
183
|
+
// Ensure the resolved path is within the project root boundary
|
|
184
|
+
if (!resolvedDirPath.startsWith(rootDir + path.sep) &&
|
|
185
|
+
resolvedDirPath !== rootDir) {
|
|
186
|
+
if (process.stdout.isTTY) {
|
|
187
|
+
console.error(`Error: ${dirName} path "${dirPath}" resolves to "${resolvedDirPath}", which is outside the project boundary "${rootDir}".`);
|
|
188
|
+
}
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
if (!existsSync(resolvedDirPath)) {
|
|
192
|
+
try {
|
|
193
|
+
mkdirSync(resolvedDirPath, { recursive: true });
|
|
194
|
+
if (process.stdout.isTTY) {
|
|
195
|
+
console.log(`Created ${dirName} directory: ${resolvedDirPath}`);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
catch (err) {
|
|
199
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
200
|
+
if (process.stdout.isTTY) {
|
|
201
|
+
console.error(`Error creating ${dirName} directory at ${resolvedDirPath}: ${errorMessage}`);
|
|
202
|
+
}
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
try {
|
|
208
|
+
const stats = statSync(resolvedDirPath);
|
|
209
|
+
if (!stats.isDirectory()) {
|
|
210
|
+
if (process.stdout.isTTY) {
|
|
211
|
+
console.error(`Error: ${dirName} path ${resolvedDirPath} exists but is not a directory.`);
|
|
212
|
+
}
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
catch (statError) {
|
|
217
|
+
if (process.stdout.isTTY) {
|
|
218
|
+
console.error(`Error accessing ${dirName} path ${resolvedDirPath}: ${statError.message}`);
|
|
219
|
+
}
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return resolvedDirPath;
|
|
224
|
+
};
|
|
225
|
+
// --- End Directory Ensurance Function ---
|
|
226
|
+
// --- Logs Directory Handling ---
|
|
227
|
+
const validatedLogsPath = ensureDirectory(env.LOGS_DIR, projectRoot, "logs");
|
|
228
|
+
if (!validatedLogsPath) {
|
|
229
|
+
if (process.stdout.isTTY) {
|
|
230
|
+
console.error("FATAL: Logs directory configuration is invalid or could not be created. Please check permissions and path. Exiting.");
|
|
231
|
+
}
|
|
232
|
+
process.exit(1); // Exit if logs directory is not usable
|
|
233
|
+
}
|
|
234
|
+
// --- End Logs Directory Handling ---
|
|
235
|
+
/**
|
|
236
|
+
* Main application configuration object.
|
|
237
|
+
* Aggregates settings from validated environment variables and `package.json`.
|
|
238
|
+
*/
|
|
239
|
+
export const config = {
|
|
240
|
+
/** Information from package.json. */
|
|
241
|
+
pkg,
|
|
242
|
+
/** MCP server name. Env `MCP_SERVER_NAME` > `package.json` name > "mcp-ts-template". */
|
|
243
|
+
mcpServerName: env.MCP_SERVER_NAME || pkg.name,
|
|
244
|
+
/** MCP server version. Env `MCP_SERVER_VERSION` > `package.json` version > "0.0.0". */
|
|
245
|
+
mcpServerVersion: env.MCP_SERVER_VERSION || pkg.version,
|
|
246
|
+
/** Logging level. From `MCP_LOG_LEVEL` env var. Default: "debug". */
|
|
247
|
+
logLevel: env.MCP_LOG_LEVEL,
|
|
248
|
+
/** Absolute path to the logs directory. From `LOGS_DIR` env var. */
|
|
249
|
+
logsPath: validatedLogsPath,
|
|
250
|
+
/** Runtime environment. From `NODE_ENV` env var. Default: "development". */
|
|
251
|
+
environment: env.NODE_ENV,
|
|
252
|
+
/** MCP transport type ('stdio' or 'http'). From `MCP_TRANSPORT_TYPE` env var. Default: "stdio". */
|
|
253
|
+
mcpTransportType: env.MCP_TRANSPORT_TYPE,
|
|
254
|
+
/** HTTP server port (if http transport). From `MCP_HTTP_PORT` env var. Default: 3010. */
|
|
255
|
+
mcpHttpPort: env.MCP_HTTP_PORT,
|
|
256
|
+
/** HTTP server host (if http transport). From `MCP_HTTP_HOST` env var. Default: "127.0.0.1". */
|
|
257
|
+
mcpHttpHost: env.MCP_HTTP_HOST,
|
|
258
|
+
/** Array of allowed CORS origins (http transport). From `MCP_ALLOWED_ORIGINS` (comma-separated). */
|
|
259
|
+
mcpAllowedOrigins: env.MCP_ALLOWED_ORIGINS?.split(",")
|
|
260
|
+
.map((origin) => origin.trim())
|
|
261
|
+
.filter(Boolean),
|
|
262
|
+
/** Auth secret key (JWTs, http transport). From `MCP_AUTH_SECRET_KEY`. CRITICAL. */
|
|
263
|
+
mcpAuthSecretKey: env.MCP_AUTH_SECRET_KEY,
|
|
264
|
+
/** The authentication mode ('jwt' or 'oauth'). From `MCP_AUTH_MODE`. */
|
|
265
|
+
mcpAuthMode: env.MCP_AUTH_MODE,
|
|
266
|
+
/** OAuth 2.1 Issuer URL. From `OAUTH_ISSUER_URL`. */
|
|
267
|
+
oauthIssuerUrl: env.OAUTH_ISSUER_URL,
|
|
268
|
+
/** OAuth 2.1 JWKS URI. From `OAUTH_JWKS_URI`. */
|
|
269
|
+
oauthJwksUri: env.OAUTH_JWKS_URI,
|
|
270
|
+
/** OAuth 2.1 Audience. From `OAUTH_AUDIENCE`. */
|
|
271
|
+
oauthAudience: env.OAUTH_AUDIENCE,
|
|
272
|
+
/** OpenRouter App URL. From `OPENROUTER_APP_URL`. Default: "http://localhost:3000". */
|
|
273
|
+
openrouterAppUrl: env.OPENROUTER_APP_URL || "http://localhost:3000",
|
|
274
|
+
/** OpenRouter App Name. From `OPENROUTER_APP_NAME`. Defaults to `mcpServerName`. */
|
|
275
|
+
openrouterAppName: env.OPENROUTER_APP_NAME || pkg.name || "MCP TS App",
|
|
276
|
+
/** OpenRouter API Key. From `OPENROUTER_API_KEY`. */
|
|
277
|
+
openrouterApiKey: env.OPENROUTER_API_KEY,
|
|
278
|
+
/** Default LLM model. From `LLM_DEFAULT_MODEL`. */
|
|
279
|
+
llmDefaultModel: env.LLM_DEFAULT_MODEL,
|
|
280
|
+
/** Default LLM temperature. From `LLM_DEFAULT_TEMPERATURE`. */
|
|
281
|
+
llmDefaultTemperature: env.LLM_DEFAULT_TEMPERATURE,
|
|
282
|
+
/** Default LLM top_p. From `LLM_DEFAULT_TOP_P`. */
|
|
283
|
+
llmDefaultTopP: env.LLM_DEFAULT_TOP_P,
|
|
284
|
+
/** Default LLM max tokens. From `LLM_DEFAULT_MAX_TOKENS`. */
|
|
285
|
+
llmDefaultMaxTokens: env.LLM_DEFAULT_MAX_TOKENS,
|
|
286
|
+
/** Default LLM top_k. From `LLM_DEFAULT_TOP_K`. */
|
|
287
|
+
llmDefaultTopK: env.LLM_DEFAULT_TOP_K,
|
|
288
|
+
/** Default LLM min_p. From `LLM_DEFAULT_MIN_P`. */
|
|
289
|
+
llmDefaultMinP: env.LLM_DEFAULT_MIN_P,
|
|
290
|
+
/** OAuth Proxy configurations. Undefined if no related env vars are set. */
|
|
291
|
+
oauthProxy: env.OAUTH_PROXY_AUTHORIZATION_URL ||
|
|
292
|
+
env.OAUTH_PROXY_TOKEN_URL ||
|
|
293
|
+
env.OAUTH_PROXY_REVOCATION_URL ||
|
|
294
|
+
env.OAUTH_PROXY_ISSUER_URL ||
|
|
295
|
+
env.OAUTH_PROXY_SERVICE_DOCUMENTATION_URL ||
|
|
296
|
+
env.OAUTH_PROXY_DEFAULT_CLIENT_REDIRECT_URIS
|
|
297
|
+
? {
|
|
298
|
+
authorizationUrl: env.OAUTH_PROXY_AUTHORIZATION_URL,
|
|
299
|
+
tokenUrl: env.OAUTH_PROXY_TOKEN_URL,
|
|
300
|
+
revocationUrl: env.OAUTH_PROXY_REVOCATION_URL,
|
|
301
|
+
issuerUrl: env.OAUTH_PROXY_ISSUER_URL,
|
|
302
|
+
serviceDocumentationUrl: env.OAUTH_PROXY_SERVICE_DOCUMENTATION_URL,
|
|
303
|
+
defaultClientRedirectUris: env.OAUTH_PROXY_DEFAULT_CLIENT_REDIRECT_URIS?.split(",")
|
|
304
|
+
.map((uri) => uri.trim())
|
|
305
|
+
.filter(Boolean),
|
|
306
|
+
}
|
|
307
|
+
: undefined,
|
|
308
|
+
/** Supabase configuration. Undefined if no related env vars are set. */
|
|
309
|
+
supabase: env.SUPABASE_URL && env.SUPABASE_ANON_KEY
|
|
310
|
+
? {
|
|
311
|
+
url: env.SUPABASE_URL,
|
|
312
|
+
anonKey: env.SUPABASE_ANON_KEY,
|
|
313
|
+
serviceRoleKey: env.SUPABASE_SERVICE_ROLE_KEY,
|
|
314
|
+
}
|
|
315
|
+
: undefined,
|
|
316
|
+
};
|
|
317
|
+
/**
|
|
318
|
+
* Configured logging level for the application.
|
|
319
|
+
* Exported for convenience.
|
|
320
|
+
*/
|
|
321
|
+
export const logLevel = config.logLevel;
|
|
322
|
+
/**
|
|
323
|
+
* Configured runtime environment ("development", "production", etc.).
|
|
324
|
+
* Exported for convenience.
|
|
325
|
+
*/
|
|
326
|
+
export const environment = config.environment;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Main entry point for the MCP TypeScript Template application.
|
|
4
|
+
* This script initializes the configuration, sets up the logger, starts the
|
|
5
|
+
* MCP server (either via STDIO or HTTP transport), and handles graceful
|
|
6
|
+
* shutdown on process signals or unhandled errors.
|
|
7
|
+
*
|
|
8
|
+
* The script uses an Immediately Invoked Function Expression (IIFE) with async/await
|
|
9
|
+
* to manage the asynchronous nature of server startup and shutdown.
|
|
10
|
+
*
|
|
11
|
+
* Key operations:
|
|
12
|
+
* 1. Import necessary modules and utilities.
|
|
13
|
+
* 2. Define a `shutdown` function for graceful server termination.
|
|
14
|
+
* 3. Define a `start` function to:
|
|
15
|
+
* - Initialize the logger with the configured log level.
|
|
16
|
+
* - Create a startup request context for logging and correlation.
|
|
17
|
+
* - Initialize and start the MCP server transport (stdio or http).
|
|
18
|
+
* - Set up global error handlers (uncaughtException, unhandledRejection)
|
|
19
|
+
* and signal handlers (SIGTERM, SIGINT) to trigger graceful shutdown.
|
|
20
|
+
* 4. Execute the `start` function within an async IIFE.
|
|
21
|
+
*
|
|
22
|
+
* @module src/index
|
|
23
|
+
*/
|
|
24
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Main entry point for the MCP TypeScript Template application.
|
|
4
|
+
* This script initializes the configuration, sets up the logger, starts the
|
|
5
|
+
* MCP server (either via STDIO or HTTP transport), and handles graceful
|
|
6
|
+
* shutdown on process signals or unhandled errors.
|
|
7
|
+
*
|
|
8
|
+
* The script uses an Immediately Invoked Function Expression (IIFE) with async/await
|
|
9
|
+
* to manage the asynchronous nature of server startup and shutdown.
|
|
10
|
+
*
|
|
11
|
+
* Key operations:
|
|
12
|
+
* 1. Import necessary modules and utilities.
|
|
13
|
+
* 2. Define a `shutdown` function for graceful server termination.
|
|
14
|
+
* 3. Define a `start` function to:
|
|
15
|
+
* - Initialize the logger with the configured log level.
|
|
16
|
+
* - Create a startup request context for logging and correlation.
|
|
17
|
+
* - Initialize and start the MCP server transport (stdio or http).
|
|
18
|
+
* - Set up global error handlers (uncaughtException, unhandledRejection)
|
|
19
|
+
* and signal handlers (SIGTERM, SIGINT) to trigger graceful shutdown.
|
|
20
|
+
* 4. Execute the `start` function within an async IIFE.
|
|
21
|
+
*
|
|
22
|
+
* @module src/index
|
|
23
|
+
*/
|
|
24
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
25
|
+
import http from "http"; // Import http module
|
|
26
|
+
import { config, environment } from "./config/index.js";
|
|
27
|
+
import { initializeAndStartServer } from "./mcp-server/server.js";
|
|
28
|
+
import { requestContextService } from "./utils/index.js";
|
|
29
|
+
import { logger } from "./utils/internal/logger.js";
|
|
30
|
+
/**
|
|
31
|
+
* Holds the main MCP server instance, primarily for STDIO transport.
|
|
32
|
+
* @private
|
|
33
|
+
*/
|
|
34
|
+
let mcpStdioServer;
|
|
35
|
+
/**
|
|
36
|
+
* Holds the Node.js HTTP server instance if HTTP transport is used.
|
|
37
|
+
* @private
|
|
38
|
+
*/
|
|
39
|
+
let actualHttpServer;
|
|
40
|
+
/**
|
|
41
|
+
* Gracefully shuts down the main MCP server and associated resources.
|
|
42
|
+
* Called on process termination signals or critical unhandled errors.
|
|
43
|
+
*
|
|
44
|
+
* @param signal - The signal or event name that triggered the shutdown.
|
|
45
|
+
* @returns A promise that resolves when shutdown is complete or an error occurs.
|
|
46
|
+
* @private
|
|
47
|
+
*/
|
|
48
|
+
const shutdown = async (signal) => {
|
|
49
|
+
const shutdownContext = requestContextService.createRequestContext({
|
|
50
|
+
operation: "ServerShutdown",
|
|
51
|
+
triggerEvent: signal,
|
|
52
|
+
});
|
|
53
|
+
logger.info(`Received ${signal}. Initiating graceful shutdown...`, shutdownContext);
|
|
54
|
+
const shutdownPromises = [];
|
|
55
|
+
if (mcpStdioServer) {
|
|
56
|
+
const serverToClose = mcpStdioServer;
|
|
57
|
+
shutdownPromises.push(new Promise((resolve) => {
|
|
58
|
+
logger.info("Closing main MCP server (STDIO)...", shutdownContext);
|
|
59
|
+
serverToClose
|
|
60
|
+
.close()
|
|
61
|
+
.then(() => {
|
|
62
|
+
logger.info("Main MCP server (STDIO) closed successfully.", shutdownContext);
|
|
63
|
+
resolve();
|
|
64
|
+
})
|
|
65
|
+
.catch((err) => {
|
|
66
|
+
logger.error("Error closing MCP server (STDIO).", {
|
|
67
|
+
...shutdownContext,
|
|
68
|
+
error: err,
|
|
69
|
+
});
|
|
70
|
+
resolve(); // Resolve even on error to not block shutdown
|
|
71
|
+
});
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
if (actualHttpServer) {
|
|
75
|
+
const serverToClose = actualHttpServer;
|
|
76
|
+
shutdownPromises.push(new Promise((resolve) => {
|
|
77
|
+
logger.info("Closing HTTP server...", shutdownContext);
|
|
78
|
+
serverToClose.close((err) => {
|
|
79
|
+
if (err) {
|
|
80
|
+
logger.error("Error closing HTTP server.", {
|
|
81
|
+
...shutdownContext,
|
|
82
|
+
error: err,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
logger.info("HTTP server closed successfully.", shutdownContext);
|
|
87
|
+
}
|
|
88
|
+
resolve(); // Resolve regardless of error
|
|
89
|
+
});
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
await Promise.allSettled(shutdownPromises);
|
|
93
|
+
logger.info("Graceful shutdown completed successfully. Exiting.", shutdownContext);
|
|
94
|
+
process.exit(0);
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Initializes and starts the main MCP server application.
|
|
98
|
+
* Orchestrates logger setup, server initialization, transport startup,
|
|
99
|
+
* and global error/signal handling.
|
|
100
|
+
*
|
|
101
|
+
* @returns A promise that resolves when the server has started and handlers are registered,
|
|
102
|
+
* or rejects if a critical startup error occurs.
|
|
103
|
+
* @private
|
|
104
|
+
*/
|
|
105
|
+
const start = async () => {
|
|
106
|
+
const validMcpLogLevels = [
|
|
107
|
+
"debug",
|
|
108
|
+
"info",
|
|
109
|
+
"notice",
|
|
110
|
+
"warning",
|
|
111
|
+
"error",
|
|
112
|
+
"crit",
|
|
113
|
+
"alert",
|
|
114
|
+
"emerg",
|
|
115
|
+
];
|
|
116
|
+
const initialLogLevelConfig = config.logLevel;
|
|
117
|
+
let validatedMcpLogLevel = "info";
|
|
118
|
+
if (validMcpLogLevels.includes(initialLogLevelConfig)) {
|
|
119
|
+
validatedMcpLogLevel = initialLogLevelConfig;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
if (process.stdout.isTTY) {
|
|
123
|
+
console.warn(`[Startup Warning] Invalid MCP_LOG_LEVEL "${initialLogLevelConfig}" found in configuration. ` +
|
|
124
|
+
`Defaulting to log level "info". Valid levels are: ${validMcpLogLevels.join(", ")}.`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
await logger.initialize(validatedMcpLogLevel);
|
|
128
|
+
logger.info(`Logger has been initialized by start(). Effective MCP logging level set to: ${validatedMcpLogLevel}.`);
|
|
129
|
+
const transportType = config.mcpTransportType;
|
|
130
|
+
const startupContext = requestContextService.createRequestContext({
|
|
131
|
+
operation: `ServerStartupSequence_${transportType}`,
|
|
132
|
+
applicationName: config.mcpServerName,
|
|
133
|
+
applicationVersion: config.mcpServerVersion,
|
|
134
|
+
nodeEnvironment: environment,
|
|
135
|
+
});
|
|
136
|
+
logger.debug("Application configuration loaded successfully.", {
|
|
137
|
+
...startupContext,
|
|
138
|
+
configSummary: {
|
|
139
|
+
serverName: config.mcpServerName,
|
|
140
|
+
serverVersion: config.mcpServerVersion,
|
|
141
|
+
transport: config.mcpTransportType,
|
|
142
|
+
logLevel: config.logLevel,
|
|
143
|
+
env: config.environment,
|
|
144
|
+
httpPort: config.mcpTransportType === "http" ? config.mcpHttpPort : undefined,
|
|
145
|
+
httpHost: config.mcpTransportType === "http" ? config.mcpHttpHost : undefined,
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
logger.info(`Starting ${config.mcpServerName} (Version: ${config.mcpServerVersion}, Transport: ${transportType}, Env: ${environment})...`, startupContext);
|
|
149
|
+
try {
|
|
150
|
+
logger.debug("Calling initializeAndStartServer to set up MCP transport...", startupContext);
|
|
151
|
+
const serverInstance = await initializeAndStartServer();
|
|
152
|
+
if (transportType === "stdio" && serverInstance instanceof McpServer) {
|
|
153
|
+
mcpStdioServer = serverInstance;
|
|
154
|
+
logger.info("STDIO McpServer instance stored globally for shutdown.", startupContext);
|
|
155
|
+
}
|
|
156
|
+
else if (transportType === "http" &&
|
|
157
|
+
serverInstance instanceof http.Server) {
|
|
158
|
+
actualHttpServer = serverInstance;
|
|
159
|
+
logger.info("HTTP transport initialized, http.Server instance stored globally for shutdown.", startupContext);
|
|
160
|
+
}
|
|
161
|
+
else if (transportType === "http") {
|
|
162
|
+
// This case should ideally not be reached if initializeAndStartServer correctly returns http.Server
|
|
163
|
+
logger.warning("HTTP transport initialized, but no http.Server instance was returned to index.ts. Shutdown might be incomplete.", startupContext);
|
|
164
|
+
}
|
|
165
|
+
logger.info(`${config.mcpServerName} is now running and ready to accept connections via ${transportType} transport.`, {
|
|
166
|
+
...startupContext,
|
|
167
|
+
serverStartTime: new Date().toISOString(),
|
|
168
|
+
});
|
|
169
|
+
process.on("SIGTERM", () => shutdown("SIGTERM"));
|
|
170
|
+
process.on("SIGINT", () => shutdown("SIGINT"));
|
|
171
|
+
process.on("uncaughtException", async (error) => {
|
|
172
|
+
const errorContext = {
|
|
173
|
+
...startupContext,
|
|
174
|
+
triggerEvent: "uncaughtException",
|
|
175
|
+
errorMessage: error.message,
|
|
176
|
+
errorStack: error.stack,
|
|
177
|
+
};
|
|
178
|
+
logger.error("FATAL: Uncaught exception detected. This indicates a bug or unexpected state. Initiating shutdown...", errorContext);
|
|
179
|
+
await shutdown("uncaughtException");
|
|
180
|
+
});
|
|
181
|
+
process.on("unhandledRejection", async (reason, promise) => {
|
|
182
|
+
const rejectionContext = {
|
|
183
|
+
...startupContext,
|
|
184
|
+
triggerEvent: "unhandledRejection",
|
|
185
|
+
rejectionReason: reason instanceof Error ? reason.message : String(reason),
|
|
186
|
+
rejectionStack: reason instanceof Error ? reason.stack : undefined,
|
|
187
|
+
};
|
|
188
|
+
logger.error("FATAL: Unhandled promise rejection detected. This indicates a bug or missing error handling in async code. Initiating shutdown...", rejectionContext);
|
|
189
|
+
await shutdown("unhandledRejection");
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
logger.error("CRITICAL ERROR DURING STARTUP: The application could not start. Exiting.", {
|
|
194
|
+
...startupContext,
|
|
195
|
+
finalErrorContext: "ApplicationStartupFailure",
|
|
196
|
+
errorMessage: error instanceof Error ? error.message : String(error),
|
|
197
|
+
errorStack: error instanceof Error ? error.stack : undefined,
|
|
198
|
+
});
|
|
199
|
+
process.exit(1);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
// Async IIFE to allow top-level await for the start function.
|
|
203
|
+
(async () => {
|
|
204
|
+
try {
|
|
205
|
+
await start();
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
// This catch is a final fallback. `start()` should handle its errors and exit.
|
|
209
|
+
if (process.stdout.isTTY) {
|
|
210
|
+
console.error("[GLOBAL CATCH] An unexpected error occurred outside of the main start function's error handling:", error);
|
|
211
|
+
}
|
|
212
|
+
process.exit(1);
|
|
213
|
+
}
|
|
214
|
+
})();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Main entry point for the MCP (Model Context Protocol) server.
|
|
3
|
+
* This file orchestrates the server's lifecycle:
|
|
4
|
+
* 1. Initializes the core `McpServer` instance (from `@modelcontextprotocol/sdk`) with its identity and capabilities.
|
|
5
|
+
* 2. Registers available resources and tools, making them discoverable and usable by clients.
|
|
6
|
+
* 3. Selects and starts the appropriate communication transport (stdio or Streamable HTTP)
|
|
7
|
+
* based on configuration.
|
|
8
|
+
* 4. Handles top-level error management during startup.
|
|
9
|
+
*
|
|
10
|
+
* MCP Specification References:
|
|
11
|
+
* - Lifecycle: https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/docs/specification/2025-03-26/basic/lifecycle.mdx
|
|
12
|
+
* - Overview (Capabilities): https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/docs/specification/2025-03-26/basic/index.mdx
|
|
13
|
+
* - Transports: https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/docs/specification/2025-03-26/basic/transports.mdx
|
|
14
|
+
* @module src/mcp-server/server
|
|
15
|
+
*/
|
|
16
|
+
import { ServerType } from "@hono/node-server";
|
|
17
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
18
|
+
/**
|
|
19
|
+
* Main application entry point. Initializes and starts the MCP server.
|
|
20
|
+
*/
|
|
21
|
+
export declare function initializeAndStartServer(): Promise<void | McpServer | ServerType>;
|