# Fetch Meta To Kb

> Fetch journal articles from Crossref published after a user-specified date and insert them into PostgreSQL `journals` with DOI deduplication. Use when incrementally ingesting journal metadata from `journals_issn` into `journals`.

- **Type:** Skill
- **Install:** `agentstack add skill-tiangong-ai-agent-skills-fetch-meta-to-kb`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [tiangong-ai](https://agentstack.voostack.com/s/tiangong-ai)
- **Installs:** 0
- **Category:** [Databases](https://agentstack.voostack.com/c/databases)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [tiangong-ai](https://github.com/tiangong-ai)
- **Source:** https://github.com/tiangong-ai/agent-skills/tree/main/fetch-meta-to-kb

## Install

```sh
agentstack add skill-tiangong-ai-agent-skills-fetch-meta-to-kb
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Fetch Meta to KB

## Core Goal
- Pull `journal-article` records from Crossref after a given `--from-date`.
- Read ISSN seed rows from `journals_issn` (`journal`, `issn1`).
- Insert rows into `journals` with `ON CONFLICT (doi) DO NOTHING`.
- Keep the implementation aligned with `fetch_meta_to_kb.py`.

## Run Workflow
1. Set database connection env vars (user-managed keys prefixed with `KB_`):
- `KB_DB_HOST`
- `KB_DB_PORT`
- `KB_DB_NAME`
- `KB_DB_USER`
- `KB_DB_PASSWORD`
- `KB_LOG_DIR` (required, log output directory)

2. Run incremental fetch with a required date:

```bash
python3 scripts/fetch_meta_to_kb.py --from-date 2024-05-01
```

- If executing through an `exec` tool call, set timeout to **1800 seconds (30 minutes)**.

3. Check logs in:
- `${KB_LOG_DIR}/fetch-meta-to-kb-YYYYMMDD-HHMMSS.log` (UTC timestamp, one file per run)

4. Build user-facing summary strictly from the current run output:
- Prefer `RUN_SUMMARY_JSON` emitted by `fetch_meta_to_kb.py`.
- If JSON is unavailable, parse only this run's `${KB_LOG_DIR}/fetch-meta-to-kb-YYYYMMDD-HHMMSS.log`.
- `total_inserted` must mean rows inserted in this run (after DOI dedup), not cumulative rows in table.

## Behavior Contract
- Query Crossref endpoint: `https://api.crossref.org/journals/{issn}/works`.
- Filter with `type:journal-article,from-pub-date:`.
- Keep only items whose `container-title` equals target journal title (case-insensitive).
- Continue pagination with cursor until no matching items remain.
- Store fields in `journals`: `title`, `doi`, `journal`, `authors`, `date`, `abstract` (nullable when Crossref has no abstract).
- Reporting/announcement metrics must use current-run log/summary only.
- Do **not** compute announcement counts via database-wide or time-window SQL such as `WHERE date >= ...`.

## Scope Boundary
- Implement only Crossref incremental fetch + insert into `journals`.

## Script
- `scripts/fetch_meta_to_kb.py`

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [tiangong-ai](https://github.com/tiangong-ai)
- **Source:** [tiangong-ai/agent-skills](https://github.com/tiangong-ai/agent-skills)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-tiangong-ai-agent-skills-fetch-meta-to-kb
- Seller: https://agentstack.voostack.com/s/tiangong-ai
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
