# augmented-nature/pubchem-mcp-server architecture

> Architecture diagram of the GitHub repository augmented-nature/pubchem-mcp-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/augmented-nature/pubchem-mcp-server
- Repository: https://github.com/augmented-nature/pubchem-mcp-server

## Overview

This is a single-file TypeScript MCP server exposing PubChem search, chemical informatics, bioassay, safety, and cross-reference capabilities as tools and URI resources. The principal workflow is an MCP client request, server dispatch, domain-specific PubChem REST request, and returned data. The implementation is concentrated in src/index.ts; README-described subsystems are represented there even where their handler excerpts were not supplied. Relationships for those unsampled capabilities rely on README documentation.

Main entry points: [`src/index.ts`](https://github.com/augmented-nature/pubchem-mcp-server/blob/main/src/index.ts) (Tool Dispatcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_protocol["MCP Interface"]
  node_server["MCP Server<br/>[index.ts]"]
  node_tools["Tool Dispatcher<br/>[index.ts]"]
  node_resources["Resource Templates<br/>[index.ts]"]
  node_validation["Input Validation<br/>[index.ts]"]
end

subgraph group_chem["Chemical Informatics"]
  node_search["Compound Search<br/>[index.ts]"]
  node_retrieval["Compound Retrieval<br/>[index.ts]"]
  node_structure["Structure Analysis<br/>[index.ts]"]
  node_properties["Properties &amp; Descriptors<br/>[index.ts]"]
end

subgraph group_bio["Bioassay Data"]
  node_assays["Bioassay &amp; Activity<br/>[index.ts]"]
end

subgraph group_safety["Safety &amp; References"]
  node_safety["Safety &amp; Toxicity<br/>[index.ts]"]
  node_references["External References<br/>[index.ts]"]
  node_batch["Batch Lookup<br/>[index.ts]"]
end

node_client(("MCP Client"))
node_pubchem["PubChem REST API"]

node_client -->|"sends MCP requests"| node_server
node_server -->|"dispatches tools"| node_tools
node_server -->|"serves templates"| node_resources
node_tools -->|"validates inputs"| node_validation
node_tools -->|"routes requests"| node_search
node_search -->|"queries compounds"| node_pubchem
node_tools -->|"routes requests"| node_retrieval
node_retrieval -->|"fetches compound data"| node_pubchem
node_tools -->|"routes requests"| node_structure
node_structure -->|"queries structures"| node_pubchem
node_tools -->|"routes requests"| node_properties
node_properties -->|"fetches properties"| node_pubchem
node_tools -->|"routes requests"| node_assays
node_assays -->|"queries assays"| node_pubchem
node_tools -->|"routes requests"| node_safety
node_safety -->|"fetches classifications"| node_pubchem
node_tools -->|"routes requests"| node_references
node_references -->|"queries references"| node_pubchem
node_tools -->|"routes requests"| node_batch
node_batch -->|"looks up compounds"| node_pubchem
node_resources -->|"fetches resource data"| node_pubchem

click node_server "https://github.com/augmented-nature/pubchem-mcp-server/blob/main/src/index.ts"
click node_tools "https://github.com/augmented-nature/pubchem-mcp-server/blob/main/src/index.ts"
click node_resources "https://github.com/augmented-nature/pubchem-mcp-server/blob/main/src/index.ts"
click node_validation "https://github.com/augmented-nature/pubchem-mcp-server/blob/main/src/index.ts"
click node_search "https://github.com/augmented-nature/pubchem-mcp-server/blob/main/src/index.ts"
click node_retrieval "https://github.com/augmented-nature/pubchem-mcp-server/blob/main/src/index.ts"
click node_structure "https://github.com/augmented-nature/pubchem-mcp-server/blob/main/src/index.ts"
click node_properties "https://github.com/augmented-nature/pubchem-mcp-server/blob/main/src/index.ts"
click node_assays "https://github.com/augmented-nature/pubchem-mcp-server/blob/main/src/index.ts"
click node_safety "https://github.com/augmented-nature/pubchem-mcp-server/blob/main/src/index.ts"
click node_references "https://github.com/augmented-nature/pubchem-mcp-server/blob/main/src/index.ts"
click node_batch "https://github.com/augmented-nature/pubchem-mcp-server/blob/main/src/index.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server,node_tools,node_resources,node_validation,node_client toneBlue
class node_search,node_retrieval,node_structure,node_properties toneAmber
class node_assays,node_pubchem toneMint
class node_safety,node_references,node_batch toneRose
```

## Components

### MCP Interface

- [MCP Server](https://github.com/augmented-nature/pubchem-mcp-server/blob/main/src/index.ts): `src/index.ts`
- [Tool Dispatcher](https://github.com/augmented-nature/pubchem-mcp-server/blob/main/src/index.ts): `src/index.ts`
- [Resource Templates](https://github.com/augmented-nature/pubchem-mcp-server/blob/main/src/index.ts): `src/index.ts`
- [Input Validation](https://github.com/augmented-nature/pubchem-mcp-server/blob/main/src/index.ts): `src/index.ts`

### Chemical Informatics

- [Compound Search](https://github.com/augmented-nature/pubchem-mcp-server/blob/main/src/index.ts): `src/index.ts`
- [Compound Retrieval](https://github.com/augmented-nature/pubchem-mcp-server/blob/main/src/index.ts): `src/index.ts`
- [Structure Analysis](https://github.com/augmented-nature/pubchem-mcp-server/blob/main/src/index.ts): `src/index.ts`
- [Properties & Descriptors](https://github.com/augmented-nature/pubchem-mcp-server/blob/main/src/index.ts): `src/index.ts`

### Bioassay Data

- [Bioassay & Activity](https://github.com/augmented-nature/pubchem-mcp-server/blob/main/src/index.ts): `src/index.ts`

### Safety & References

- [Safety & Toxicity](https://github.com/augmented-nature/pubchem-mcp-server/blob/main/src/index.ts): `src/index.ts`
- [External References](https://github.com/augmented-nature/pubchem-mcp-server/blob/main/src/index.ts): `src/index.ts`
- [Batch Lookup](https://github.com/augmented-nature/pubchem-mcp-server/blob/main/src/index.ts): `src/index.ts`

### Other components

- **MCP Client**
- **PubChem REST API**

## Connections

- MCP Client → MCP Server: sends MCP requests (evidence: `README.md`)
- MCP Server → Tool Dispatcher: dispatches tools (evidence: `src/index.ts`)
- MCP Server → Resource Templates: serves templates (evidence: `README.md`)
- Tool Dispatcher → Input Validation: validates inputs (evidence: `README.md`)
- Tool Dispatcher → Compound Search: routes requests (evidence: `src/index.ts`)
- Compound Search → PubChem REST API: queries compounds (evidence: `src/index.ts`)
- Tool Dispatcher → Compound Retrieval: routes requests (evidence: `README.md`)
- Compound Retrieval → PubChem REST API: fetches compound data (evidence: `src/index.ts`)
- Tool Dispatcher → Structure Analysis: routes requests (evidence: `README.md`)
- Structure Analysis → PubChem REST API: queries structures (evidence: `src/index.ts`)
- Tool Dispatcher → Properties & Descriptors: routes requests (evidence: `README.md`)
- Properties & Descriptors → PubChem REST API: fetches properties (evidence: `src/index.ts`)
- Tool Dispatcher → Bioassay & Activity: routes requests (evidence: `README.md`)
- Bioassay & Activity → PubChem REST API: queries assays (evidence: `src/index.ts`)
- Tool Dispatcher → Safety & Toxicity: routes requests (evidence: `README.md`)
- Safety & Toxicity → PubChem REST API: fetches classifications (evidence: `src/index.ts`)
- Tool Dispatcher → External References: routes requests (evidence: `README.md`)
- External References → PubChem REST API: queries references (evidence: `README.md`)
- Tool Dispatcher → Batch Lookup: routes requests (evidence: `README.md`)
- Batch Lookup → PubChem REST API: looks up compounds (evidence: `README.md`)
- Resource Templates → PubChem REST API: fetches resource data (evidence: `src/index.ts`)
