---
name: huagongshe-aichem
description: Use the HGS AIchem remote MCP server (https://huagongshe.com/mcp) to search chemicals and reactions, inspect pure HCID compound records, discover suppliers and catalogs, run HCID-anchored inquiry and quote workflows, manage chemistry notes, calculate stoichiometry, browse reusable chemistry skills, and curate personal datasets.
---

# HGS AIchem Agent Skill

This is the official website-level Agent Skill for **HGS AIchem** (`https://huagongshe.com`).
It explains how an AI agent should connect to and orchestrate the 34 MCP tools hosted at `https://huagongshe.com/mcp`.

> Note: This document is the HGS AIchem platform Agent Skill (independent from the community Skills Registry browsed at `https://huagongshe.com/skills` or via `list_skills` / `get_skill`).

## 1. Connection & Authorization Model

- **Endpoint**: `https://huagongshe.com/mcp` (MCP Streamable HTTP, stateless).
- **Anonymous-first**: Connecting (`initialize`), tool discovery (`tools/list`), exact search, pure compound detail, public suppliers and catalogs, public inquiries, public notes, public reactions, 2D SVG rendering, and stoichiometry work with no account.
- **On-demand OAuth 2.1 (PKCE S256)**: Calling any restricted read or write tool without credentials returns `HTTP 401` with `WWW-Authenticate` (`resource_metadata` + exact required `scope`). Calling with a token missing a scope returns `HTTP 403` (`error="insufficient_scope"`).
- **AI Key compatibility**: Hosts without OAuth support send `Authorization: Bearer <AI Key>` (created by the user at `https://huagongshe.com/me/settings/api-tokens`). Never send an AI Key to any domain other than `huagongshe.com`, and never retry an invalid credential as an anonymous request.

### OAuth Scopes (8 total)

| Scope | Grants |
|-------|--------|
| `read` | Substructure/similarity search, `list_skills` / `get_skill`, `list_my_reactions`, `list_my_datasets` / `list_my_dataset_records`, `get_my_org`, `list_inquiries(mine=true)`, owner view in `get_inquiry`, `list_quotes`, `list_notes(mine=true)`, private owner view in `get_note` / `get_reaction` / `render_reaction_svg` |
| `reaction:write` | `validate_reaction`, `create_reaction` |
| `skill:write` | `validate_skill`, `create_skill` |
| `dataset:write` | `save_dataset`, `delete_dataset`, `upsert_dataset_records`, `delete_dataset_records` |
| `note:write` | `save_note`, `delete_note` |
| `inquiry:write` | `save_inquiry`, `close_inquiry` |
| `quote:write` | `save_quote`, `delete_quote` |
| `org:write` | `save_my_org` |

## 2. Core Mental Model: HCID as the Pure Chemical Anchor

- **HCID** (`chemical_id`, positive integer) is the canonical compound identifier on HGS AIchem.
- **HRID** (`reaction_id`, positive integer) is the canonical reaction identifier.
- **`get_chemical` is intentionally pure**: it returns chemical identity, structure, synonyms, properties, safety, applications, and related products. It does **not** embed suppliers, inquiries, quotes, or notes.
- Every surrounding workflow anchors onto HCID (or HRID) through dedicated domain tools:
  - Suppliers & Organization: `list_chemical_suppliers`, `get_supplier_catalog`, `get_my_org`, `save_my_org`
  - Commercial Inquiries: `list_inquiries`, `get_inquiry`, `save_inquiry`, `close_inquiry`
  - Private Quotes: `list_quotes`, `save_quote`, `delete_quote`
  - Chemistry Notes: `list_notes`, `get_note`, `save_note`, `delete_note`
  - Reactions & Stoichiometry: `get_reaction`, `render_molecule_svg`, `render_reaction_svg`, `calculate_stoichiometry`, `list_my_reactions`, `validate_reaction`, `create_reaction`
  - Community & Personal Skills Registry: `list_skills`, `get_skill`, `validate_skill`, `create_skill`
  - Personal Chemical Datasets: `list_my_datasets`, `list_my_dataset_records`, `save_dataset`, `delete_dataset`, `upsert_dataset_records`, `delete_dataset_records`

## 3. Complete Tool Surface (34 Tools)

### Chemistry, Search & Structure (6)
1. `search_chemistry_data(q, mode="exact", threshold=0.7, page=1, page_size=30)` — `exact` is anonymous (name, CAS, HCID, InChIKey, DOI, SMILES); `substructure` / `similarity` require `read`. Check `has_more` for pagination, `lookup_pending=true` for async CAS discovery, and `capped=true` for 250-result substructure caps.
2. `get_chemical(chemical_id, enrich="core")` — Anonymous. `enrich="core"` returns identity/structure/counts; `enrich="full"` adds properties, safety, applications, and upstream/downstream products.
3. `get_reaction(reaction_id)` — Public reactions anonymous; owner private reactions with `read`.
4. `render_molecule_svg(chemical_id | smiles, width=400, height=300)` — Anonymous. Pass either `chemical_id` or `smiles` (<= 512 chars).
5. `render_reaction_svg(reaction_id, width=800, height=300)` — Public reactions anonymous; owner private reactions with `read`.
6. `calculate_stoichiometry(components, basis_index, basis_amount, ...)` — Anonymous. Pure scale-up calculation; never persists a reaction.

### Suppliers & Organizations (4)
7. `list_chemical_suppliers(chemical_id, page=1, page_size=20)` — Anonymous. Paginated public suppliers for one HCID (`slug`, `name`, `country_code`, `phone`, `email`, `website`, `verified`, `verified_at`, `purity`, `package_price`, `remark`).
8. `get_supplier_catalog(org_slug, page=1, page_size=20)` — Anonymous. Public organization card and paginated product catalog by 7-character `org_slug`.
9. `get_my_org()` — Requires `read`. Returns `has_organization` and the user's single organization profile, role (`admin` | `collaborator`), and verification summary.
10. `save_my_org(org_type, name, country_code, name_en, short_name, website, phone, email, description)` — Requires `org:write`. Creates the caller's organization if none exists (`org_type`, `name`, `country_code` required), or partially updates it if the caller is an active `admin` (pass `""` to clear an optional field).

### Commercial Inquiries (4)
11. `list_inquiries(chemical_id=None, mine=False, state=None, page=1, page_size=20)` — `mine=false` (anonymous) requires `chemical_id` and lists open public inquiries (no quote counts); `mine=true` (`read`) lists the caller's own inquiries with `quote_count` and optional `chemical_id` / `state` (`open` | `ended`) filters.
12. `get_inquiry(slug)` — Anonymous gets the public share view (only fields authorized by `share_*` flags; ended inquiries return an ended error); with `read`, the inquiry creator gets `view="owner"` (full demand, contact, share flags, state, events).
13. `save_inquiry(slug=None, chemical_id=None, quantity=None, unit=None, ...)` — Requires `inquiry:write`. Omit `slug` to create (requires `chemical_id`, `quantity`, `unit`; if the user has no organization, pass `org_type`, `org_name`, `org_country_code` inline or call `save_my_org` first; duplicate open inquiry on the same HCID returns `existing=true`). Provide `slug` to update an open inquiry you own.
14. `close_inquiry(slug, delete=False, reason=None)` — Requires `inquiry:write`. `delete=false` closes the inquiry (keeps history); `delete=true` permanently soft-deletes it from your view.

### Private Quotes (3)
15. `list_quotes(inquiry_slug=None, page=1, page_size=20)` — Requires `read`. With `inquiry_slug`, lists quotes received on an inquiry **you created** (third parties receive not found). Without `inquiry_slug`, lists quotes **you submitted**.
16. `save_quote(inquiry_slug=None, quote_slug=None, ...)` — Requires `quote:write`. Provide exactly one of `inquiry_slug` (create) or `quote_slug` (update). Self-quoting on your own inquiry is forbidden. Provide `spec_purity`, `contact_name`, at least one contact channel (`contact_email` / `contact_phone` / `contact_im`), and either `negotiable=true` OR (`price_amount`, `currency`, `price_unit`). On create, `add_to_catalog` defaults to `true` and inline `org_*` fields are supported if the caller has no org.
17. `delete_quote(quote_slug)` — Requires `quote:write`. Soft-deletes your own quote from both sides.

### Chemistry Notes (4)
18. `list_notes(chemical_id=None, reaction_id=None, mine=False, visibility=None, page=1, page_size=20)` — `mine=false` (anonymous) requires exactly one of `chemical_id` or `reaction_id` and returns public notes with 400-char `excerpt`. `mine=true` (`read`) lists the caller's own notes (`visibility`: `all` | `public` | `private`).
19. `get_note(slug)` — Returns full Markdown `content`. Public notes are anonymous; private notes require `read` and ownership.
20. `save_note(slug=None, content=None, title=None, visibility=None, chemical_ids=None, reaction_ids=None)` — Requires `note:write`. Omit `slug` to create (`content` required, defaults to `visibility="private"`, up to 20 combined HCID/HRID anchors). Provide `slug` to partially update a note you own (`title=""` clears the title).
21. `delete_note(slug)` — Requires `note:write`. Permanently deletes a note you own.

### Workbench Reactions (3)
22. `list_my_reactions(visibility="all", page=1, page_size=20)` — Requires `read`.
23. `validate_reaction(reaction)` — Requires `reaction:write`. Validates and canonicalizes a reaction draft without saving.
24. `create_reaction(reaction, idempotency_key)` — Requires `reaction:write`. Always call `validate_reaction` first, show the draft for confirmation, default `visibility="private"`, and reuse the same `idempotency_key` on retry.

### Skills Registry (4)
25. `list_skills(scope="public", q="", category="", page=1, page_size=30)` — Requires `read`. Browses community public skills or the caller's own skills.
26. `get_skill(skill_id)` — Requires `read`. Accepts numeric ID or slug; returns manifest, file list, and `SKILL.md` text.
27. `validate_skill(zip_base64, category="general")` — Requires `skill:write`.
28. `create_skill(zip_base64, idempotency_key, category="general")` — Requires `skill:write`. Always saved private.

### Personal Chemical Datasets (6)
29. `list_my_datasets(q=None, page=1, page_size=20)` — Requires `read`.
30. `list_my_dataset_records(code, q=None, status=None, page=1, page_size=20)` — Requires `read`.
31. `save_dataset(code, name=None, ...)` — Requires `dataset:write`. Create or partial update; defaults to `private`.
32. `delete_dataset(code)` — Requires `dataset:write`. Soft-deletes owned dataset and its records.
33. `upsert_dataset_records(code, items)` — Requires `dataset:write`. 1–50 items per call; resolves or creates HCID automatically.
34. `delete_dataset_records(code, record_ids=None, hcid=None)` — Requires `dataset:write`.

## 4. Recommended Agent Playbooks

### A. Compound Research + Sourcing Discovery (Anonymous)
1. Call `search_chemistry_data(q="<name or CAS or SMILES>", mode="exact")` to resolve the canonical `chemical_id` (HCID).
2. Call `get_chemical(chemical_id=HCID, enrich="full")` for properties, safety, and applications.
3. Call `list_chemical_suppliers(chemical_id=HCID)` for public suppliers; follow any supplier `slug` with `get_supplier_catalog(org_slug=slug)` to see its full profile and other offerings.
4. Optionally call `list_inquiries(chemical_id=HCID)` and `list_notes(chemical_id=HCID)` to check open demand and public lab notes.

### B. Buyer Inquiry Closed Loop (`read` + `inquiry:write`, optional `org:write`)
1. Resolve the compound HCID via `search_chemistry_data`.
2. Call `get_my_org()` to check whether the user already belongs to an organization.
   - If `has_organization=true`, do **not** pass `org_type` / `org_name` / `org_country_code` in `save_inquiry`.
   - If `has_organization=false`, ask the user for organization type, name, and 2-letter ISO country code, and either create it via `save_my_org` or pass `org_type` + `org_name` + `org_country_code` inline to `save_inquiry`.
3. Present the exact inquiry parameters (HCID, quantity, unit, purity, delivery, visibility, contact share flags) to the user and get confirmation.
4. Call `save_inquiry(...)`. Note `existing=true` means an open inquiry for that HCID already exists.
5. Later, call `list_quotes(inquiry_slug=slug)` to review received quotes, or `close_inquiry(slug, delete=False|True)` after user confirmation.

### C. Supplier Quoting Closed Loop (`read` + `quote:write`, optional `org:write`)
1. Find open public demand via `list_inquiries(chemical_id=HCID)` and inspect details via `get_inquiry(slug)`.
2. Check `get_my_org()` so you know whether inline `org_*` fields are needed.
3. Confirm pricing (`negotiable=true` or `price_amount` + 3-letter `currency` + `price_unit`), `spec_purity`, contact details, and whether `add_to_catalog` should stay `true`.
4. Call `save_quote(inquiry_slug=slug, ...)`. Never attempt to quote the user's own inquiry.
5. Manage submitted quotes via `list_quotes()` (no `inquiry_slug`), `save_quote(quote_slug=...)`, or `delete_quote(quote_slug)`.

### D. HCID / HRID Chemistry Notes (`read` + `note:write`)
1. Read public notes with `list_notes(chemical_id=HCID)` or `list_notes(reaction_id=HRID)`, and full text with `get_note(slug)`.
2. Read the user's own notes with `list_notes(mine=True, chemical_id=HCID)`.
3. Draft Markdown content, confirm with the user, default `visibility="private"`, and call `save_note(...)`. Obtain explicit confirmation before setting `visibility="public"`.

## 5. Non-Negotiable Safety & Accuracy Guardrails

- **Confirm every write or destructive action**: Always show the draft/target to the user before calling `create_reaction`, `create_skill`, `save_dataset`, `delete_dataset`, `upsert_dataset_records`, `delete_dataset_records`, `save_my_org`, `save_inquiry`, `close_inquiry`, `save_quote`, `delete_quote`, `save_note`, or `delete_note`.
- **Private by default**: New reactions, datasets, and notes must default to `private` unless the user explicitly asks to make them `public`.
- **Zero fabrication**: Never invent SMILES, CAS numbers, HCIDs, DOIs, reaction conditions, yields, supplier prices, or contact information. Present conflicting property values from different sources side by side.
- **Quote privacy**: Quotes are strictly private between the inquiry creator and the quoter. Never claim to view quotes on third-party inquiries.
- **Honest error handling**: On rate-limit (`429`) or busy errors, ask the user to wait or narrow the query rather than looping or prompting re-login.
