@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,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Defines the core logic, schemas, and types for the `pubchem_get_compound_image` tool.
|
|
3
|
+
* This tool fetches the raw image data for a given compound.
|
|
4
|
+
* @module src/mcp-server/tools/getCompoundImage/logic
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { type RequestContext } from "../../../utils/index.js";
|
|
8
|
+
export declare const PubchemGetCompoundImageInputSchema: z.ZodObject<{
|
|
9
|
+
cid: z.ZodNumber;
|
|
10
|
+
size: z.ZodDefault<z.ZodOptional<z.ZodEnum<["small", "large"]>>>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
cid: number;
|
|
13
|
+
size: "small" | "large";
|
|
14
|
+
}, {
|
|
15
|
+
cid: number;
|
|
16
|
+
size?: "small" | "large" | undefined;
|
|
17
|
+
}>;
|
|
18
|
+
export type PubchemGetCompoundImageInput = z.infer<typeof PubchemGetCompoundImageInputSchema>;
|
|
19
|
+
export declare const PubchemGetCompoundImageOutputSchema: z.ZodObject<{
|
|
20
|
+
cid: z.ZodNumber;
|
|
21
|
+
blob: z.ZodType<Buffer<ArrayBufferLike>, z.ZodTypeDef, Buffer<ArrayBufferLike>>;
|
|
22
|
+
mimeType: z.ZodString;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
mimeType: string;
|
|
25
|
+
blob: Buffer<ArrayBufferLike>;
|
|
26
|
+
cid: number;
|
|
27
|
+
}, {
|
|
28
|
+
mimeType: string;
|
|
29
|
+
blob: Buffer<ArrayBufferLike>;
|
|
30
|
+
cid: number;
|
|
31
|
+
}>;
|
|
32
|
+
export type PubchemGetCompoundImageOutput = z.infer<typeof PubchemGetCompoundImageOutputSchema>;
|
|
33
|
+
/**
|
|
34
|
+
* Core logic for the `pubchem_get_compound_image` tool. It constructs the image URL,
|
|
35
|
+
* fetches the image data, and returns it as a blob.
|
|
36
|
+
*
|
|
37
|
+
* @param {PubchemGetCompoundImageInput} params - The validated input parameters.
|
|
38
|
+
* @param {RequestContext} context - The request context for logging and tracing.
|
|
39
|
+
* @returns {Promise<PubchemGetCompoundImageOutput>} A promise that resolves with the image blob and metadata.
|
|
40
|
+
* @throws {McpError} Throws a structured error if the image fetch fails or the CID is invalid.
|
|
41
|
+
*/
|
|
42
|
+
export declare function pubchemGetCompoundImageLogic(params: PubchemGetCompoundImageInput, context: RequestContext): Promise<PubchemGetCompoundImageOutput>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Defines the core logic, schemas, and types for the `pubchem_get_compound_image` tool.
|
|
3
|
+
* This tool fetches the raw image data for a given compound.
|
|
4
|
+
* @module src/mcp-server/tools/getCompoundImage/logic
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { pubChemApiClient } from "../../../services/pubchem/pubchemApiClient.js";
|
|
8
|
+
import { BaseErrorCode, McpError } from "../../../types-global/errors.js";
|
|
9
|
+
import { logger } from "../../../utils/index.js";
|
|
10
|
+
// 1. Define and export the Zod schema for input validation
|
|
11
|
+
export const PubchemGetCompoundImageInputSchema = z.object({
|
|
12
|
+
cid: z
|
|
13
|
+
.number()
|
|
14
|
+
.int()
|
|
15
|
+
.positive()
|
|
16
|
+
.describe("The PubChem Compound ID (CID) for which to fetch the image. Must be a positive integer."),
|
|
17
|
+
size: z
|
|
18
|
+
.enum(["small", "large"])
|
|
19
|
+
.optional()
|
|
20
|
+
.default("large")
|
|
21
|
+
.describe("Specifies the desired image size: 'small' (100x100) or 'large' (300x300). Defaults to 'large'."),
|
|
22
|
+
});
|
|
23
|
+
// 3. Define and export the Zod schema for the tool's output
|
|
24
|
+
export const PubchemGetCompoundImageOutputSchema = z.object({
|
|
25
|
+
cid: z
|
|
26
|
+
.number()
|
|
27
|
+
.int()
|
|
28
|
+
.describe("The CID of the compound depicted in the image."),
|
|
29
|
+
blob: z.instanceof(Buffer).describe("The raw image data as a Buffer object."),
|
|
30
|
+
mimeType: z
|
|
31
|
+
.string()
|
|
32
|
+
.describe("The MIME type of the image (e.g., 'image/png')."),
|
|
33
|
+
});
|
|
34
|
+
const PUBCHEM_IMAGE_BASE_URL = "https://pubchem.ncbi.nlm.nih.gov/rest/pug";
|
|
35
|
+
/**
|
|
36
|
+
* Core logic for the `pubchem_get_compound_image` tool. It constructs the image URL,
|
|
37
|
+
* fetches the image data, and returns it as a blob.
|
|
38
|
+
*
|
|
39
|
+
* @param {PubchemGetCompoundImageInput} params - The validated input parameters.
|
|
40
|
+
* @param {RequestContext} context - The request context for logging and tracing.
|
|
41
|
+
* @returns {Promise<PubchemGetCompoundImageOutput>} A promise that resolves with the image blob and metadata.
|
|
42
|
+
* @throws {McpError} Throws a structured error if the image fetch fails or the CID is invalid.
|
|
43
|
+
*/
|
|
44
|
+
export async function pubchemGetCompoundImageLogic(params, context) {
|
|
45
|
+
logger.debug("Processing pubchem_get_compound_image logic...", {
|
|
46
|
+
...context,
|
|
47
|
+
params,
|
|
48
|
+
});
|
|
49
|
+
const { cid, size } = params;
|
|
50
|
+
const imageUrl = `${PUBCHEM_IMAGE_BASE_URL}/compound/cid/${cid}/PNG?record_type=2d&image_size=${size}`;
|
|
51
|
+
try {
|
|
52
|
+
const arrayBuffer = await pubChemApiClient.getBlob(imageUrl, context);
|
|
53
|
+
const result = {
|
|
54
|
+
cid,
|
|
55
|
+
blob: Buffer.from(arrayBuffer),
|
|
56
|
+
mimeType: "image/png",
|
|
57
|
+
};
|
|
58
|
+
logger.info(`Successfully fetched image for CID ${cid}.`, context);
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
logger.error(`Failed to fetch image for CID ${cid} from ${imageUrl}`, {
|
|
63
|
+
...context,
|
|
64
|
+
error,
|
|
65
|
+
});
|
|
66
|
+
throw new McpError(BaseErrorCode.EXTERNAL_SERVICE_ERROR, `Failed to fetch image for CID ${cid}. The compound may not exist or there was a network issue.`, { ...context, cid, imageUrl });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Handles the registration of the `pubchem_get_compound_image` tool.
|
|
3
|
+
* @module src/mcp-server/tools/getCompoundImage/registration
|
|
4
|
+
*/
|
|
5
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
|
+
/**
|
|
7
|
+
* Registers the 'pubchem_get_compound_image' tool with the MCP server.
|
|
8
|
+
* This tool fetches a 2D image of a compound's structure and returns it as a binary blob.
|
|
9
|
+
*
|
|
10
|
+
* @param {McpServer} server - The MCP server instance to register the tool with.
|
|
11
|
+
*/
|
|
12
|
+
export declare const registerPubchemGetCompoundImageTool: (server: McpServer) => Promise<void>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Handles the registration of the `pubchem_get_compound_image` tool.
|
|
3
|
+
* @module src/mcp-server/tools/getCompoundImage/registration
|
|
4
|
+
*/
|
|
5
|
+
import { ErrorHandler, logger, requestContextService, } from "../../../utils/index.js";
|
|
6
|
+
import { PubchemGetCompoundImageInputSchema, pubchemGetCompoundImageLogic, } from "./logic.js";
|
|
7
|
+
/**
|
|
8
|
+
* Registers the 'pubchem_get_compound_image' tool with the MCP server.
|
|
9
|
+
* This tool fetches a 2D image of a compound's structure and returns it as a binary blob.
|
|
10
|
+
*
|
|
11
|
+
* @param {McpServer} server - The MCP server instance to register the tool with.
|
|
12
|
+
*/
|
|
13
|
+
export const registerPubchemGetCompoundImageTool = async (server) => {
|
|
14
|
+
const toolName = "pubchem_get_compound_image";
|
|
15
|
+
const toolDescription = "Fetches a 2D image of a compound's structure for a given PubChem CID and returns the raw image data as a binary blob. Ideal for displaying chemical structures directly.";
|
|
16
|
+
server.tool(toolName, toolDescription, PubchemGetCompoundImageInputSchema.shape, async (params, mcpContext) => {
|
|
17
|
+
const handlerContext = requestContextService.createRequestContext({
|
|
18
|
+
operation: "HandleToolRequest",
|
|
19
|
+
toolName,
|
|
20
|
+
mcpToolContext: mcpContext,
|
|
21
|
+
input: params,
|
|
22
|
+
});
|
|
23
|
+
try {
|
|
24
|
+
logger.info(`Initiating tool request for ${toolName} for CID: ${params.cid}`, handlerContext);
|
|
25
|
+
const result = await pubchemGetCompoundImageLogic(params, handlerContext);
|
|
26
|
+
return {
|
|
27
|
+
content: [
|
|
28
|
+
{
|
|
29
|
+
type: "image",
|
|
30
|
+
data: result.blob.toString("base64"),
|
|
31
|
+
mimeType: result.mimeType,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
isError: false,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
const handledError = ErrorHandler.handleError(error, {
|
|
39
|
+
operation: "pubchemGetCompoundImageToolHandler",
|
|
40
|
+
context: handlerContext,
|
|
41
|
+
input: params,
|
|
42
|
+
});
|
|
43
|
+
// No need to log here, handleError already does it.
|
|
44
|
+
return {
|
|
45
|
+
content: [
|
|
46
|
+
{
|
|
47
|
+
type: "text",
|
|
48
|
+
text: JSON.stringify({
|
|
49
|
+
error: ErrorHandler.formatError(handledError),
|
|
50
|
+
}),
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
isError: true,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Barrel file for the `pubchem_search_assays_by_target` tool.
|
|
3
|
+
* This file serves as the public interface for the tool module,
|
|
4
|
+
* primarily exporting the `registerPubchemSearchAssaysByTargetTool` function.
|
|
5
|
+
* @module src/mcp-server/tools/searchAssaysByTarget/index
|
|
6
|
+
*/
|
|
7
|
+
export { registerPubchemSearchAssaysByTargetTool } from "./registration.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Barrel file for the `pubchem_search_assays_by_target` tool.
|
|
3
|
+
* This file serves as the public interface for the tool module,
|
|
4
|
+
* primarily exporting the `registerPubchemSearchAssaysByTargetTool` function.
|
|
5
|
+
* @module src/mcp-server/tools/searchAssaysByTarget/index
|
|
6
|
+
*/
|
|
7
|
+
export { registerPubchemSearchAssaysByTargetTool } from "./registration.js";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Defines the core logic, schemas, and types for the `pubchem_search_assays_by_target` tool.
|
|
3
|
+
* @module src/mcp-server/tools/searchAssaysByTarget/logic
|
|
4
|
+
*/
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { type RequestContext } from "../../../utils/index.js";
|
|
7
|
+
export declare const PubchemSearchAssaysByTargetInputSchema: z.ZodObject<{
|
|
8
|
+
targetType: z.ZodEnum<["genesymbol", "proteinname"]>;
|
|
9
|
+
targetQuery: z.ZodString;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
targetType: "genesymbol" | "proteinname";
|
|
12
|
+
targetQuery: string;
|
|
13
|
+
}, {
|
|
14
|
+
targetType: "genesymbol" | "proteinname";
|
|
15
|
+
targetQuery: string;
|
|
16
|
+
}>;
|
|
17
|
+
export type PubchemSearchAssaysByTargetInput = z.infer<typeof PubchemSearchAssaysByTargetInputSchema>;
|
|
18
|
+
export declare const PubchemSearchAssaysByTargetOutputSchema: z.ZodObject<{
|
|
19
|
+
aids: z.ZodArray<z.ZodNumber, "many">;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
aids: number[];
|
|
22
|
+
}, {
|
|
23
|
+
aids: number[];
|
|
24
|
+
}>;
|
|
25
|
+
export type PubchemSearchAssaysByTargetOutput = z.infer<typeof PubchemSearchAssaysByTargetOutputSchema>;
|
|
26
|
+
/**
|
|
27
|
+
* Core logic for the `pubchem_search_assays_by_target` tool. It finds BioAssay IDs (AIDs)
|
|
28
|
+
* associated with a specific biological target.
|
|
29
|
+
*
|
|
30
|
+
* @param {PubchemSearchAssaysByTargetInput} params - The validated input parameters.
|
|
31
|
+
* @param {RequestContext} context - The request context for logging and tracing.
|
|
32
|
+
* @returns {Promise<PubchemSearchAssaysByTargetOutput>} A promise that resolves with a list of AIDs.
|
|
33
|
+
* @throws {McpError} Throws a structured error if the API request fails or returns a fault.
|
|
34
|
+
*/
|
|
35
|
+
export declare function pubchemSearchAssaysByTargetLogic(params: PubchemSearchAssaysByTargetInput, context: RequestContext): Promise<PubchemSearchAssaysByTargetOutput>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Defines the core logic, schemas, and types for the `pubchem_search_assays_by_target` tool.
|
|
3
|
+
* @module src/mcp-server/tools/searchAssaysByTarget/logic
|
|
4
|
+
*/
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { pubChemApiClient } from "../../../services/pubchem/pubchemApiClient.js";
|
|
7
|
+
import { BaseErrorCode, McpError } from "../../../types-global/errors.js";
|
|
8
|
+
import { logger } from "../../../utils/index.js";
|
|
9
|
+
// 1. Define and export the Zod schema for input validation
|
|
10
|
+
export const PubchemSearchAssaysByTargetInputSchema = z.object({
|
|
11
|
+
targetType: z
|
|
12
|
+
.enum(["genesymbol", "proteinname"])
|
|
13
|
+
.describe("The type of biological target to search by."),
|
|
14
|
+
targetQuery: z
|
|
15
|
+
.string()
|
|
16
|
+
.min(1, "Target query cannot be empty.")
|
|
17
|
+
.describe("The identifier for the target, such as 'EGFR' for a gene symbol or 'Epidermal growth factor receptor' for a protein name."),
|
|
18
|
+
});
|
|
19
|
+
// 3. Define and export the Zod schema for the tool's output
|
|
20
|
+
export const PubchemSearchAssaysByTargetOutputSchema = z.object({
|
|
21
|
+
aids: z
|
|
22
|
+
.array(z.number().int())
|
|
23
|
+
.describe("A list of PubChem BioAssay IDs (AIDs) associated with the specified target."),
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* Core logic for the `pubchem_search_assays_by_target` tool. It finds BioAssay IDs (AIDs)
|
|
27
|
+
* associated with a specific biological target.
|
|
28
|
+
*
|
|
29
|
+
* @param {PubchemSearchAssaysByTargetInput} params - The validated input parameters.
|
|
30
|
+
* @param {RequestContext} context - The request context for logging and tracing.
|
|
31
|
+
* @returns {Promise<PubchemSearchAssaysByTargetOutput>} A promise that resolves with a list of AIDs.
|
|
32
|
+
* @throws {McpError} Throws a structured error if the API request fails or returns a fault.
|
|
33
|
+
*/
|
|
34
|
+
export async function pubchemSearchAssaysByTargetLogic(params, context) {
|
|
35
|
+
logger.debug("Processing pubchem_search_assays_by_target logic...", {
|
|
36
|
+
...context,
|
|
37
|
+
params,
|
|
38
|
+
});
|
|
39
|
+
const { targetType, targetQuery } = params;
|
|
40
|
+
const path = `/assay/target/${targetType}/${encodeURIComponent(targetQuery)}/aids/JSON`;
|
|
41
|
+
const response = await pubChemApiClient.get(path, context);
|
|
42
|
+
logger.debug("Raw PubChem response for pubchem_search_assays_by_target", {
|
|
43
|
+
...context,
|
|
44
|
+
response,
|
|
45
|
+
});
|
|
46
|
+
if (response?.Fault) {
|
|
47
|
+
logger.error("PubChem API returned a fault for target search.", {
|
|
48
|
+
...context,
|
|
49
|
+
fault: response.Fault,
|
|
50
|
+
});
|
|
51
|
+
throw new McpError(BaseErrorCode.EXTERNAL_SERVICE_ERROR, `PubChem API Fault: ${response.Fault.Message}`, { ...context, details: response.Fault.Details });
|
|
52
|
+
}
|
|
53
|
+
if (!response ||
|
|
54
|
+
!response.IdentifierList?.AID ||
|
|
55
|
+
!Array.isArray(response.IdentifierList.AID)) {
|
|
56
|
+
logger.warning("No AIDs found for the target search, or the response format was unexpected. Returning empty list.", { ...context, targetQuery, response });
|
|
57
|
+
return { aids: [] };
|
|
58
|
+
}
|
|
59
|
+
const result = {
|
|
60
|
+
aids: response.IdentifierList.AID,
|
|
61
|
+
};
|
|
62
|
+
logger.info(`Found ${result.aids.length} AIDs for target query '${targetQuery}'.`, context);
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Handles the registration of the `pubchem_search_assays_by_target` tool.
|
|
3
|
+
* @module src/mcp-server/tools/searchAssaysByTarget/registration
|
|
4
|
+
*/
|
|
5
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
|
+
/**
|
|
7
|
+
* Registers the 'pubchem_search_assays_by_target' tool with the MCP server.
|
|
8
|
+
* This tool finds PubChem BioAssay IDs (AIDs) associated with a specific biological target.
|
|
9
|
+
*
|
|
10
|
+
* @param {McpServer} server - The MCP server instance to register the tool with.
|
|
11
|
+
*/
|
|
12
|
+
export declare const registerPubchemSearchAssaysByTargetTool: (server: McpServer) => Promise<void>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Handles the registration of the `pubchem_search_assays_by_target` tool.
|
|
3
|
+
* @module src/mcp-server/tools/searchAssaysByTarget/registration
|
|
4
|
+
*/
|
|
5
|
+
import { BaseErrorCode, McpError } from "../../../types-global/errors.js";
|
|
6
|
+
import { ErrorHandler, logger, requestContextService, } from "../../../utils/index.js";
|
|
7
|
+
import { PubchemSearchAssaysByTargetInputSchema, pubchemSearchAssaysByTargetLogic, } from "./logic.js";
|
|
8
|
+
/**
|
|
9
|
+
* Registers the 'pubchem_search_assays_by_target' tool with the MCP server.
|
|
10
|
+
* This tool finds PubChem BioAssay IDs (AIDs) associated with a specific biological target.
|
|
11
|
+
*
|
|
12
|
+
* @param {McpServer} server - The MCP server instance to register the tool with.
|
|
13
|
+
*/
|
|
14
|
+
export const registerPubchemSearchAssaysByTargetTool = async (server) => {
|
|
15
|
+
const toolName = "pubchem_search_assays_by_target";
|
|
16
|
+
const toolDescription = "Finds PubChem BioAssay IDs (AIDs) associated with a specific biological target, such as a gene symbol (e.g., 'EGFR') or a full protein name.";
|
|
17
|
+
server.tool(toolName, toolDescription, PubchemSearchAssaysByTargetInputSchema.shape, async (params, mcpContext) => {
|
|
18
|
+
const handlerContext = requestContextService.createRequestContext({
|
|
19
|
+
operation: "HandleToolRequest",
|
|
20
|
+
toolName,
|
|
21
|
+
mcpToolContext: mcpContext,
|
|
22
|
+
input: params,
|
|
23
|
+
});
|
|
24
|
+
try {
|
|
25
|
+
logger.info(`Initiating tool request for ${toolName} for target: '${params.targetQuery}'`, handlerContext);
|
|
26
|
+
const result = await pubchemSearchAssaysByTargetLogic(params, handlerContext);
|
|
27
|
+
return {
|
|
28
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
29
|
+
isError: false,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
const handledError = ErrorHandler.handleError(error, {
|
|
34
|
+
operation: "pubchemSearchAssaysByTargetToolHandler",
|
|
35
|
+
context: handlerContext,
|
|
36
|
+
input: params,
|
|
37
|
+
});
|
|
38
|
+
const mcpError = handledError instanceof McpError
|
|
39
|
+
? handledError
|
|
40
|
+
: new McpError(BaseErrorCode.INTERNAL_ERROR, "An unexpected error occurred while searching for assays by target.", { originalErrorName: handledError.name });
|
|
41
|
+
logger.error(`Error in ${toolName} handler`, {
|
|
42
|
+
...handlerContext,
|
|
43
|
+
error: mcpError,
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
content: [
|
|
47
|
+
{
|
|
48
|
+
type: "text",
|
|
49
|
+
text: JSON.stringify({
|
|
50
|
+
error: {
|
|
51
|
+
code: mcpError.code,
|
|
52
|
+
message: mcpError.message,
|
|
53
|
+
details: mcpError.details,
|
|
54
|
+
},
|
|
55
|
+
}),
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
isError: true,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Barrel file for the `pubchem_search_compound_by_identifier` tool.
|
|
3
|
+
* This file serves as the public interface for the tool module,
|
|
4
|
+
* primarily exporting the `registerPubchemSearchCompoundByIdentifierTool` function.
|
|
5
|
+
* @module src/mcp-server/tools/searchCompoundByIdentifier/index
|
|
6
|
+
*/
|
|
7
|
+
export { registerPubchemSearchCompoundByIdentifierTool } from "./registration.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Barrel file for the `pubchem_search_compound_by_identifier` tool.
|
|
3
|
+
* This file serves as the public interface for the tool module,
|
|
4
|
+
* primarily exporting the `registerPubchemSearchCompoundByIdentifierTool` function.
|
|
5
|
+
* @module src/mcp-server/tools/searchCompoundByIdentifier/index
|
|
6
|
+
*/
|
|
7
|
+
export { registerPubchemSearchCompoundByIdentifierTool } from "./registration.js";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Defines the core logic, schemas, and types for the `pubchem_search_compound_by_identifier` tool.
|
|
3
|
+
* @module src/mcp-server/tools/searchCompoundByIdentifier/logic
|
|
4
|
+
*/
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { type RequestContext } from "../../../utils/index.js";
|
|
7
|
+
export declare const PubchemSearchCompoundByIdentifierInputSchema: z.ZodObject<{
|
|
8
|
+
identifierType: z.ZodEnum<["name", "smiles", "inchikey"]>;
|
|
9
|
+
identifiers: z.ZodArray<z.ZodString, "many">;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
identifierType: "name" | "smiles" | "inchikey";
|
|
12
|
+
identifiers: string[];
|
|
13
|
+
}, {
|
|
14
|
+
identifierType: "name" | "smiles" | "inchikey";
|
|
15
|
+
identifiers: string[];
|
|
16
|
+
}>;
|
|
17
|
+
export type PubchemSearchCompoundByIdentifierInput = z.infer<typeof PubchemSearchCompoundByIdentifierInputSchema>;
|
|
18
|
+
export declare const PubchemSearchCompoundByIdentifierOutputSchema: z.ZodObject<{
|
|
19
|
+
results: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodNumber, "many">>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
results: Record<string, number[]>;
|
|
22
|
+
}, {
|
|
23
|
+
results: Record<string, number[]>;
|
|
24
|
+
}>;
|
|
25
|
+
export type PubchemSearchCompoundByIdentifierOutput = z.infer<typeof PubchemSearchCompoundByIdentifierOutputSchema>;
|
|
26
|
+
/**
|
|
27
|
+
* Core logic for the `pubchem_search_compound_by_identifier` tool.
|
|
28
|
+
* It searches for PubChem Compound IDs (CIDs) using a common chemical identifier.
|
|
29
|
+
*
|
|
30
|
+
* @param {PubchemSearchCompoundByIdentifierInput} params - The validated input parameters.
|
|
31
|
+
* @param {RequestContext} context - The request context for logging and tracing.
|
|
32
|
+
* @returns {Promise<PubchemSearchCompoundByIdentifierOutput>} A promise that resolves with the search results.
|
|
33
|
+
* @throws {McpError} Throws a structured error if the API request fails, the identifier is not found, or the response is malformed.
|
|
34
|
+
*/
|
|
35
|
+
export declare function pubchemSearchCompoundByIdentifierLogic(params: PubchemSearchCompoundByIdentifierInput, context: RequestContext): Promise<PubchemSearchCompoundByIdentifierOutput>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Defines the core logic, schemas, and types for the `pubchem_search_compound_by_identifier` tool.
|
|
3
|
+
* @module src/mcp-server/tools/searchCompoundByIdentifier/logic
|
|
4
|
+
*/
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { pubChemApiClient } from "../../../services/pubchem/pubchemApiClient.js";
|
|
7
|
+
import { logger } from "../../../utils/index.js";
|
|
8
|
+
// 1. Define and export the Zod schema for input validation
|
|
9
|
+
export const PubchemSearchCompoundByIdentifierInputSchema = z.object({
|
|
10
|
+
identifierType: z
|
|
11
|
+
.enum(["name", "smiles", "inchikey"])
|
|
12
|
+
.describe("The type of chemical identifier being provided."),
|
|
13
|
+
identifiers: z
|
|
14
|
+
.array(z.string().min(1, "Identifier cannot be empty."))
|
|
15
|
+
.min(1, "At least one identifier must be provided.")
|
|
16
|
+
.describe("An array of identifier strings. Examples: ['aspirin', 'ibuprofen'] for name."),
|
|
17
|
+
});
|
|
18
|
+
// 3. Define and export the Zod schema for the tool's output
|
|
19
|
+
export const PubchemSearchCompoundByIdentifierOutputSchema = z.object({
|
|
20
|
+
results: z
|
|
21
|
+
.record(z.array(z.number().int()))
|
|
22
|
+
.describe("An object mapping each input identifier to an array of matching PubChem Compound IDs (CIDs)."),
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Core logic for the `pubchem_search_compound_by_identifier` tool.
|
|
26
|
+
* It searches for PubChem Compound IDs (CIDs) using a common chemical identifier.
|
|
27
|
+
*
|
|
28
|
+
* @param {PubchemSearchCompoundByIdentifierInput} params - The validated input parameters.
|
|
29
|
+
* @param {RequestContext} context - The request context for logging and tracing.
|
|
30
|
+
* @returns {Promise<PubchemSearchCompoundByIdentifierOutput>} A promise that resolves with the search results.
|
|
31
|
+
* @throws {McpError} Throws a structured error if the API request fails, the identifier is not found, or the response is malformed.
|
|
32
|
+
*/
|
|
33
|
+
export async function pubchemSearchCompoundByIdentifierLogic(params, context) {
|
|
34
|
+
logger.debug("Processing pubchem_search_compound_by_identifier logic...", {
|
|
35
|
+
...context,
|
|
36
|
+
params,
|
|
37
|
+
});
|
|
38
|
+
const { identifierType, identifiers } = params;
|
|
39
|
+
const results = {};
|
|
40
|
+
const promises = identifiers.map(async (identifier) => {
|
|
41
|
+
const path = `/compound/${identifierType}/${encodeURIComponent(identifier)}/cids/JSON`;
|
|
42
|
+
try {
|
|
43
|
+
const response = await pubChemApiClient.get(path, context);
|
|
44
|
+
if (response?.IdentifierList?.CID) {
|
|
45
|
+
results[identifier] = response.IdentifierList.CID;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
results[identifier] = [];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
logger.warning(`API call failed for identifier '${identifier}'. It will be omitted from the results.`, { ...context, error });
|
|
53
|
+
results[identifier] = [];
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
await Promise.all(promises);
|
|
57
|
+
logger.info(`Completed search for ${identifiers.length} identifiers.`, context);
|
|
58
|
+
return { results };
|
|
59
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Handles the registration of the `pubchem_search_compound_by_identifier` tool.
|
|
3
|
+
* @module src/mcp-server/tools/searchCompoundByIdentifier/registration
|
|
4
|
+
*/
|
|
5
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
|
+
/**
|
|
7
|
+
* Registers the 'pubchem_search_compound_by_identifier' tool with the MCP server.
|
|
8
|
+
* This tool searches for a PubChem Compound ID (CID) using a common chemical identifier.
|
|
9
|
+
*
|
|
10
|
+
* @param {McpServer} server - The MCP server instance to register the tool with.
|
|
11
|
+
*/
|
|
12
|
+
export declare const registerPubchemSearchCompoundByIdentifierTool: (server: McpServer) => Promise<void>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Handles the registration of the `pubchem_search_compound_by_identifier` tool.
|
|
3
|
+
* @module src/mcp-server/tools/searchCompoundByIdentifier/registration
|
|
4
|
+
*/
|
|
5
|
+
import { ErrorHandler, logger, requestContextService, } from "../../../utils/index.js";
|
|
6
|
+
import { PubchemSearchCompoundByIdentifierInputSchema, pubchemSearchCompoundByIdentifierLogic, } from "./logic.js";
|
|
7
|
+
/**
|
|
8
|
+
* Registers the 'pubchem_search_compound_by_identifier' tool with the MCP server.
|
|
9
|
+
* This tool searches for a PubChem Compound ID (CID) using a common chemical identifier.
|
|
10
|
+
*
|
|
11
|
+
* @param {McpServer} server - The MCP server instance to register the tool with.
|
|
12
|
+
*/
|
|
13
|
+
export const registerPubchemSearchCompoundByIdentifierTool = async (server) => {
|
|
14
|
+
const toolName = "pubchem_search_compound_by_identifier";
|
|
15
|
+
const toolDescription = "Searches for PubChem Compound IDs (CIDs) using a list of common chemical identifiers like names (e.g., ['aspirin', 'ibuprofen']), SMILES strings, or InChIKeys. This is the first step for most compound-related workflows.";
|
|
16
|
+
server.tool(toolName, toolDescription, PubchemSearchCompoundByIdentifierInputSchema.shape, async (params, mcpContext) => {
|
|
17
|
+
const handlerContext = requestContextService.createRequestContext({
|
|
18
|
+
operation: "HandleToolRequest",
|
|
19
|
+
toolName,
|
|
20
|
+
mcpToolContext: mcpContext,
|
|
21
|
+
input: params,
|
|
22
|
+
});
|
|
23
|
+
try {
|
|
24
|
+
logger.info(`Initiating tool request for ${toolName} for identifiers: '${params.identifiers.join(", ")}'`, handlerContext);
|
|
25
|
+
const result = await pubchemSearchCompoundByIdentifierLogic(params, handlerContext);
|
|
26
|
+
return {
|
|
27
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
28
|
+
isError: false,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
const handledError = ErrorHandler.handleError(error, {
|
|
33
|
+
operation: "pubchemSearchCompoundByIdentifierToolHandler",
|
|
34
|
+
context: handlerContext,
|
|
35
|
+
input: params,
|
|
36
|
+
});
|
|
37
|
+
// No need to log here, handleError already does it.
|
|
38
|
+
return {
|
|
39
|
+
content: [
|
|
40
|
+
{
|
|
41
|
+
type: "text",
|
|
42
|
+
text: JSON.stringify({
|
|
43
|
+
error: ErrorHandler.formatError(handledError),
|
|
44
|
+
}),
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
isError: true,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Barrel file for the `pubchem_search_compounds_by_formula` tool.
|
|
3
|
+
* This file serves as the public interface for the tool module,
|
|
4
|
+
* primarily exporting the `registerPubchemSearchCompoundsByFormulaTool` function.
|
|
5
|
+
* @module src/mcp-server/tools/searchCompoundsByFormula/index
|
|
6
|
+
*/
|
|
7
|
+
export { registerPubchemSearchCompoundsByFormulaTool } from "./registration.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Barrel file for the `pubchem_search_compounds_by_formula` tool.
|
|
3
|
+
* This file serves as the public interface for the tool module,
|
|
4
|
+
* primarily exporting the `registerPubchemSearchCompoundsByFormulaTool` function.
|
|
5
|
+
* @module src/mcp-server/tools/searchCompoundsByFormula/index
|
|
6
|
+
*/
|
|
7
|
+
export { registerPubchemSearchCompoundsByFormulaTool } from "./registration.js";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Defines the core logic, schemas, and types for the `pubchem_search_compounds_by_formula` tool.
|
|
3
|
+
* @module src/mcp-server/tools/searchCompoundsByFormula/logic
|
|
4
|
+
*/
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { type RequestContext } from "../../../utils/index.js";
|
|
7
|
+
export declare const PubchemSearchCompoundsByFormulaInputSchema: z.ZodObject<{
|
|
8
|
+
formula: z.ZodString;
|
|
9
|
+
allowOtherElements: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
10
|
+
maxRecords: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
maxRecords: number;
|
|
13
|
+
formula: string;
|
|
14
|
+
allowOtherElements: boolean;
|
|
15
|
+
}, {
|
|
16
|
+
formula: string;
|
|
17
|
+
maxRecords?: number | undefined;
|
|
18
|
+
allowOtherElements?: boolean | undefined;
|
|
19
|
+
}>;
|
|
20
|
+
export type PubchemSearchCompoundsByFormulaInput = z.infer<typeof PubchemSearchCompoundsByFormulaInputSchema>;
|
|
21
|
+
export declare const PubchemSearchCompoundsByFormulaOutputSchema: z.ZodObject<{
|
|
22
|
+
cids: z.ZodArray<z.ZodNumber, "many">;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
cids: number[];
|
|
25
|
+
}, {
|
|
26
|
+
cids: number[];
|
|
27
|
+
}>;
|
|
28
|
+
export type PubchemSearchCompoundsByFormulaOutput = z.infer<typeof PubchemSearchCompoundsByFormulaOutputSchema>;
|
|
29
|
+
/**
|
|
30
|
+
* Core logic for the `pubchem_search_compounds_by_formula` tool. It finds compounds
|
|
31
|
+
* that match a given molecular formula.
|
|
32
|
+
*
|
|
33
|
+
* @param {PubchemSearchCompoundsByFormulaInput} params - The validated input parameters.
|
|
34
|
+
* @param {RequestContext} context - The request context for logging and tracing.
|
|
35
|
+
* @returns {Promise<PubchemSearchCompoundsByFormulaOutput>} A promise that resolves with a list of matching CIDs.
|
|
36
|
+
* @throws {McpError} Throws a structured error if the API request fails or returns a fault.
|
|
37
|
+
*/
|
|
38
|
+
export declare function pubchemSearchCompoundsByFormulaLogic(params: PubchemSearchCompoundsByFormulaInput, context: RequestContext): Promise<PubchemSearchCompoundsByFormulaOutput>;
|