citeguard-mcp 0.1.2__tar.gz
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.
- citeguard_mcp-0.1.2/LICENSE +21 -0
- citeguard_mcp-0.1.2/PKG-INFO +171 -0
- citeguard_mcp-0.1.2/README.md +138 -0
- citeguard_mcp-0.1.2/pyproject.toml +64 -0
- citeguard_mcp-0.1.2/setup.cfg +4 -0
- citeguard_mcp-0.1.2/src/citeguard_mcp/__init__.py +20 -0
- citeguard_mcp-0.1.2/src/citeguard_mcp/__main__.py +6 -0
- citeguard_mcp-0.1.2/src/citeguard_mcp/cli.py +222 -0
- citeguard_mcp-0.1.2/src/citeguard_mcp/server.py +317 -0
- citeguard_mcp-0.1.2/src/citeguard_mcp/verifier.py +658 -0
- citeguard_mcp-0.1.2/src/citeguard_mcp.egg-info/PKG-INFO +171 -0
- citeguard_mcp-0.1.2/src/citeguard_mcp.egg-info/SOURCES.txt +15 -0
- citeguard_mcp-0.1.2/src/citeguard_mcp.egg-info/dependency_links.txt +1 -0
- citeguard_mcp-0.1.2/src/citeguard_mcp.egg-info/entry_points.txt +3 -0
- citeguard_mcp-0.1.2/src/citeguard_mcp.egg-info/requires.txt +3 -0
- citeguard_mcp-0.1.2/src/citeguard_mcp.egg-info/top_level.txt +1 -0
- citeguard_mcp-0.1.2/tests/test_citeguard.py +132 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Luca Celebrano
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: citeguard-mcp
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Zero-config MCP Server & CLI to detect LLM hallucinated citations, verify DOIs/PMIDs/arXiv IDs, flag retracted papers, and fetch verified BibTeX from Crossref, DataCite, PubMed, OpenAlex & arXiv.
|
|
5
|
+
Author-email: Luca Celebrano <luca.celebrano1@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Lukecele/citeguard-mcp
|
|
8
|
+
Project-URL: PyPI, https://pypi.org/project/citeguard-mcp/
|
|
9
|
+
Project-URL: Repository, https://github.com/Lukecele/citeguard-mcp
|
|
10
|
+
Project-URL: Issues, https://github.com/Lukecele/citeguard-mcp/issues
|
|
11
|
+
Project-URL: Author, https://lucacelebrano.me
|
|
12
|
+
Keywords: mcp,model-context-protocol,citation-verification,hallucination-detection,doi,pubmed,arxiv,crossref,openalex,bibtex,llm-guardrails,claude-code,cursor,scientific-writing
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering
|
|
25
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
26
|
+
Classifier: Topic :: Text Processing :: Markup :: LaTeX
|
|
27
|
+
Requires-Python: >=3.10
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=7.4.0; extra == "dev"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
<div align="center">
|
|
35
|
+
|
|
36
|
+
# 🛡️ CiteGuard MCP (`citeguard-mcp`)
|
|
37
|
+
|
|
38
|
+
**Stop LLMs from Hallucinating Fake Papers, Chimera DOIs, and Retracted Citations.**
|
|
39
|
+
*Zero-config Model Context Protocol (MCP) Server & CLI for Claude Code, Cursor, Windsurf, VS Code Copilot, and CI/CD pipelines.*
|
|
40
|
+
|
|
41
|
+
[](https://github.com/Lukecele/citeguard-mcp/actions/workflows/ci.yml)
|
|
42
|
+
[](https://pypi.org/project/citeguard-mcp/)
|
|
43
|
+
[](https://glama.ai/mcp/servers/Lukecele/citeguard-mcp)
|
|
44
|
+
[](https://www.python.org/)
|
|
45
|
+
[](https://modelcontextprotocol.io/)
|
|
46
|
+
[](./pyproject.toml)
|
|
47
|
+
[](./LICENSE)
|
|
48
|
+
|
|
49
|
+
<img src="./assets/demo.svg" alt="CiteGuard MCP Terminal & Anti-Hallucination Audit Demo" width="880" />
|
|
50
|
+
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
> [!TIP]
|
|
56
|
+
> ⭐ **If CiteGuard saves you from an embarrassing hallucinated citation in a paper, grant, PR, or technical report, please consider starring this repository!**
|
|
57
|
+
|
|
58
|
+
## 🚨 Why CiteGuard?
|
|
59
|
+
|
|
60
|
+
Even frontier LLMs frequently fail at scientific and technical citations in **three insidious ways**:
|
|
61
|
+
|
|
62
|
+
1. ❌ **Fabricated Identifiers (`FABRICATED_OR_UNRESOLVED`)**: Inventing plausible-looking DOIs (`10.1038/s41591-025-99999-z`), PubMed PMIDs, or arXiv IDs that return `404`.
|
|
63
|
+
2. ⚠️ **Chimera Citations (`CHIMERA_MISMATCH`)**: Grabbing a **real DOI** from a famous paper (so naive regex/HTTP checks pass!) but attaching a **completely fabricated title, wrong author, or wrong year**.
|
|
64
|
+
3. 🚨 **Silent Retractions (`RETRACTED`)**: Citing papers that have been formally **retracted** in Crossref, PubMed, or OpenAlex.
|
|
65
|
+
|
|
66
|
+
**`citeguard-mcp`** solves all three with **zero API keys** and **zero third-party Python dependencies** (100% Python standard library), querying **Crossref, DataCite (CERN Zenodo), PubMed (NCBI E-utilities), OpenAlex, and arXiv** in real time.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## ⚡ 10-Second Quickstart
|
|
71
|
+
|
|
72
|
+
### 1. Plug into Claude Code / Claude Desktop / Cursor / Windsurf (MCP Server)
|
|
73
|
+
|
|
74
|
+
#### Claude Code (CLI)
|
|
75
|
+
```bash
|
|
76
|
+
claude mcp add citeguard -- uvx citeguard-mcp serve
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
#### Cursor / Claude Desktop / Windsurf (`mcp.json` or `claude_desktop_config.json`)
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"mcpServers": {
|
|
83
|
+
"citeguard": {
|
|
84
|
+
"command": "uvx",
|
|
85
|
+
"args": ["citeguard-mcp", "serve"]
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
#### Docker / GHCR (`ghcr.io/lukecele/citeguard-mcp` · Official MCP Registry `io.github.Lukecele/citeguard-mcp`)
|
|
92
|
+
```json
|
|
93
|
+
{
|
|
94
|
+
"mcpServers": {
|
|
95
|
+
"citeguard": {
|
|
96
|
+
"command": "docker",
|
|
97
|
+
"args": ["run", "-i", "--rm", "ghcr.io/lukecele/citeguard-mcp:0.1.2"]
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### 2. Run Directly from the Terminal (CLI)
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
# Install via pip / pipx / uv (or run zero-install with: uvx citeguard-mcp --help)
|
|
107
|
+
pip install citeguard-mcp
|
|
108
|
+
|
|
109
|
+
# 1. Audit an entire Markdown manuscript, LaTeX file, or BibTeX bibliography
|
|
110
|
+
citeguard audit manuscript.md --strict
|
|
111
|
+
citeguard audit references.bib
|
|
112
|
+
|
|
113
|
+
# 2. Verify a single DOI + detect Chimera title/author/year hallucinations
|
|
114
|
+
citeguard verify "10.1038/s41586-021-03819-2" \
|
|
115
|
+
--title "Highly accurate protein structure prediction with AlphaFold" \
|
|
116
|
+
--author "Jumper" --year 2021
|
|
117
|
+
|
|
118
|
+
# 3. Search 100% verified literature across OpenAlex, PubMed, Crossref & arXiv
|
|
119
|
+
citeguard search "spatial transcriptomics drug resistance" --limit 5
|
|
120
|
+
|
|
121
|
+
# 4. Generate clean, deterministic BibTeX from a mix of DOIs, PMIDs, and arXiv IDs
|
|
122
|
+
citeguard bibtex 10.1038/s41586-021-03819-2 PMID:34265844 arXiv:1706.03762
|
|
123
|
+
|
|
124
|
+
# 5. Check if a DOI has been retracted
|
|
125
|
+
citeguard retraction "10.1016/S0140-6736(97)11096-0"
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## 🧰 MCP Tools Exposed to Your AI Agent
|
|
131
|
+
|
|
132
|
+
| Tool Name | Description | Registries Queried |
|
|
133
|
+
| :--- | :--- | :--- |
|
|
134
|
+
| **`verify_citation`** | Verifies a DOI, `PMID:xxxx`, `arXiv:xxxx.xxxxx`, or paper title. Checks claimed title, author, and year to catch **Chimera hallucinations** and **retractions**. Returns canonical BibTeX & APA. | Crossref · DataCite/Zenodo · PubMed · OpenAlex · arXiv |
|
|
135
|
+
| **`audit_document_citations`** | Scans an entire Markdown, LaTeX, BibTeX, or draft LLM response concurrently and returns a **Citation Integrity Score (0–100%)** with per-citation diagnostics. | All 5 registries (concurrent thread pool) |
|
|
136
|
+
| **`search_verified_literature`** | Searches for real, peer-reviewed / preprint papers **before** the LLM writes a citation, returning verified DOIs, citation counts, open-access PDFs, and BibTeX. | OpenAlex · PubMed (NCBI) · arXiv |
|
|
137
|
+
| **`generate_bibtex`** | Resolves an array of DOIs, PMIDs, and arXiv IDs into normalized `@article{...}` BibTeX blocks. | Crossref · DataCite · PubMed · arXiv |
|
|
138
|
+
| **`check_retraction`** | Checks Crossref `update-to` notices and OpenAlex `is_retracted` metadata for retractions or expressions of concern. | Crossref · OpenAlex |
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## 🤖 CI/CD Guardrail for GitHub Pull Requests
|
|
143
|
+
|
|
144
|
+
Prevent hallucinated or broken DOIs/BibTeX entries from ever being merged into your documentation or papers:
|
|
145
|
+
|
|
146
|
+
```yaml
|
|
147
|
+
- name: Audit citations with CiteGuard
|
|
148
|
+
run: |
|
|
149
|
+
pip install citeguard-mcp
|
|
150
|
+
citeguard audit paper.md --strict
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## 🧪 Running Tests
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
git clone https://github.com/Lukecele/citeguard-mcp.git
|
|
159
|
+
cd citeguard-mcp
|
|
160
|
+
pip install -e ".[dev]"
|
|
161
|
+
pytest -v
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## 👤 Author & License
|
|
167
|
+
|
|
168
|
+
Created by **[Luca Celebrano](https://lucacelebrano.me)** ([@Lukecele](https://github.com/Lukecele) · ORCID [`0009-0007-0931-3555`](https://orcid.org/0009-0007-0931-3555)).
|
|
169
|
+
Released under the [MIT License](./LICENSE).
|
|
170
|
+
|
|
171
|
+
<!-- mcp-name: io.github.Lukecele/citeguard-mcp -->
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# 🛡️ CiteGuard MCP (`citeguard-mcp`)
|
|
4
|
+
|
|
5
|
+
**Stop LLMs from Hallucinating Fake Papers, Chimera DOIs, and Retracted Citations.**
|
|
6
|
+
*Zero-config Model Context Protocol (MCP) Server & CLI for Claude Code, Cursor, Windsurf, VS Code Copilot, and CI/CD pipelines.*
|
|
7
|
+
|
|
8
|
+
[](https://github.com/Lukecele/citeguard-mcp/actions/workflows/ci.yml)
|
|
9
|
+
[](https://pypi.org/project/citeguard-mcp/)
|
|
10
|
+
[](https://glama.ai/mcp/servers/Lukecele/citeguard-mcp)
|
|
11
|
+
[](https://www.python.org/)
|
|
12
|
+
[](https://modelcontextprotocol.io/)
|
|
13
|
+
[](./pyproject.toml)
|
|
14
|
+
[](./LICENSE)
|
|
15
|
+
|
|
16
|
+
<img src="./assets/demo.svg" alt="CiteGuard MCP Terminal & Anti-Hallucination Audit Demo" width="880" />
|
|
17
|
+
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
> [!TIP]
|
|
23
|
+
> ⭐ **If CiteGuard saves you from an embarrassing hallucinated citation in a paper, grant, PR, or technical report, please consider starring this repository!**
|
|
24
|
+
|
|
25
|
+
## 🚨 Why CiteGuard?
|
|
26
|
+
|
|
27
|
+
Even frontier LLMs frequently fail at scientific and technical citations in **three insidious ways**:
|
|
28
|
+
|
|
29
|
+
1. ❌ **Fabricated Identifiers (`FABRICATED_OR_UNRESOLVED`)**: Inventing plausible-looking DOIs (`10.1038/s41591-025-99999-z`), PubMed PMIDs, or arXiv IDs that return `404`.
|
|
30
|
+
2. ⚠️ **Chimera Citations (`CHIMERA_MISMATCH`)**: Grabbing a **real DOI** from a famous paper (so naive regex/HTTP checks pass!) but attaching a **completely fabricated title, wrong author, or wrong year**.
|
|
31
|
+
3. 🚨 **Silent Retractions (`RETRACTED`)**: Citing papers that have been formally **retracted** in Crossref, PubMed, or OpenAlex.
|
|
32
|
+
|
|
33
|
+
**`citeguard-mcp`** solves all three with **zero API keys** and **zero third-party Python dependencies** (100% Python standard library), querying **Crossref, DataCite (CERN Zenodo), PubMed (NCBI E-utilities), OpenAlex, and arXiv** in real time.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## ⚡ 10-Second Quickstart
|
|
38
|
+
|
|
39
|
+
### 1. Plug into Claude Code / Claude Desktop / Cursor / Windsurf (MCP Server)
|
|
40
|
+
|
|
41
|
+
#### Claude Code (CLI)
|
|
42
|
+
```bash
|
|
43
|
+
claude mcp add citeguard -- uvx citeguard-mcp serve
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
#### Cursor / Claude Desktop / Windsurf (`mcp.json` or `claude_desktop_config.json`)
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"mcpServers": {
|
|
50
|
+
"citeguard": {
|
|
51
|
+
"command": "uvx",
|
|
52
|
+
"args": ["citeguard-mcp", "serve"]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
#### Docker / GHCR (`ghcr.io/lukecele/citeguard-mcp` · Official MCP Registry `io.github.Lukecele/citeguard-mcp`)
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"mcpServers": {
|
|
62
|
+
"citeguard": {
|
|
63
|
+
"command": "docker",
|
|
64
|
+
"args": ["run", "-i", "--rm", "ghcr.io/lukecele/citeguard-mcp:0.1.2"]
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 2. Run Directly from the Terminal (CLI)
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Install via pip / pipx / uv (or run zero-install with: uvx citeguard-mcp --help)
|
|
74
|
+
pip install citeguard-mcp
|
|
75
|
+
|
|
76
|
+
# 1. Audit an entire Markdown manuscript, LaTeX file, or BibTeX bibliography
|
|
77
|
+
citeguard audit manuscript.md --strict
|
|
78
|
+
citeguard audit references.bib
|
|
79
|
+
|
|
80
|
+
# 2. Verify a single DOI + detect Chimera title/author/year hallucinations
|
|
81
|
+
citeguard verify "10.1038/s41586-021-03819-2" \
|
|
82
|
+
--title "Highly accurate protein structure prediction with AlphaFold" \
|
|
83
|
+
--author "Jumper" --year 2021
|
|
84
|
+
|
|
85
|
+
# 3. Search 100% verified literature across OpenAlex, PubMed, Crossref & arXiv
|
|
86
|
+
citeguard search "spatial transcriptomics drug resistance" --limit 5
|
|
87
|
+
|
|
88
|
+
# 4. Generate clean, deterministic BibTeX from a mix of DOIs, PMIDs, and arXiv IDs
|
|
89
|
+
citeguard bibtex 10.1038/s41586-021-03819-2 PMID:34265844 arXiv:1706.03762
|
|
90
|
+
|
|
91
|
+
# 5. Check if a DOI has been retracted
|
|
92
|
+
citeguard retraction "10.1016/S0140-6736(97)11096-0"
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## 🧰 MCP Tools Exposed to Your AI Agent
|
|
98
|
+
|
|
99
|
+
| Tool Name | Description | Registries Queried |
|
|
100
|
+
| :--- | :--- | :--- |
|
|
101
|
+
| **`verify_citation`** | Verifies a DOI, `PMID:xxxx`, `arXiv:xxxx.xxxxx`, or paper title. Checks claimed title, author, and year to catch **Chimera hallucinations** and **retractions**. Returns canonical BibTeX & APA. | Crossref · DataCite/Zenodo · PubMed · OpenAlex · arXiv |
|
|
102
|
+
| **`audit_document_citations`** | Scans an entire Markdown, LaTeX, BibTeX, or draft LLM response concurrently and returns a **Citation Integrity Score (0–100%)** with per-citation diagnostics. | All 5 registries (concurrent thread pool) |
|
|
103
|
+
| **`search_verified_literature`** | Searches for real, peer-reviewed / preprint papers **before** the LLM writes a citation, returning verified DOIs, citation counts, open-access PDFs, and BibTeX. | OpenAlex · PubMed (NCBI) · arXiv |
|
|
104
|
+
| **`generate_bibtex`** | Resolves an array of DOIs, PMIDs, and arXiv IDs into normalized `@article{...}` BibTeX blocks. | Crossref · DataCite · PubMed · arXiv |
|
|
105
|
+
| **`check_retraction`** | Checks Crossref `update-to` notices and OpenAlex `is_retracted` metadata for retractions or expressions of concern. | Crossref · OpenAlex |
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 🤖 CI/CD Guardrail for GitHub Pull Requests
|
|
110
|
+
|
|
111
|
+
Prevent hallucinated or broken DOIs/BibTeX entries from ever being merged into your documentation or papers:
|
|
112
|
+
|
|
113
|
+
```yaml
|
|
114
|
+
- name: Audit citations with CiteGuard
|
|
115
|
+
run: |
|
|
116
|
+
pip install citeguard-mcp
|
|
117
|
+
citeguard audit paper.md --strict
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## 🧪 Running Tests
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
git clone https://github.com/Lukecele/citeguard-mcp.git
|
|
126
|
+
cd citeguard-mcp
|
|
127
|
+
pip install -e ".[dev]"
|
|
128
|
+
pytest -v
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## 👤 Author & License
|
|
134
|
+
|
|
135
|
+
Created by **[Luca Celebrano](https://lucacelebrano.me)** ([@Lukecele](https://github.com/Lukecele) · ORCID [`0009-0007-0931-3555`](https://orcid.org/0009-0007-0931-3555)).
|
|
136
|
+
Released under the [MIT License](./LICENSE).
|
|
137
|
+
|
|
138
|
+
<!-- mcp-name: io.github.Lukecele/citeguard-mcp -->
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "citeguard-mcp"
|
|
7
|
+
version = "0.1.2"
|
|
8
|
+
description = "Zero-config MCP Server & CLI to detect LLM hallucinated citations, verify DOIs/PMIDs/arXiv IDs, flag retracted papers, and fetch verified BibTeX from Crossref, DataCite, PubMed, OpenAlex & arXiv."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Luca Celebrano", email = "luca.celebrano1@gmail.com" }
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"mcp",
|
|
17
|
+
"model-context-protocol",
|
|
18
|
+
"citation-verification",
|
|
19
|
+
"hallucination-detection",
|
|
20
|
+
"doi",
|
|
21
|
+
"pubmed",
|
|
22
|
+
"arxiv",
|
|
23
|
+
"crossref",
|
|
24
|
+
"openalex",
|
|
25
|
+
"bibtex",
|
|
26
|
+
"llm-guardrails",
|
|
27
|
+
"claude-code",
|
|
28
|
+
"cursor",
|
|
29
|
+
"scientific-writing"
|
|
30
|
+
]
|
|
31
|
+
classifiers = [
|
|
32
|
+
"Development Status :: 5 - Production/Stable",
|
|
33
|
+
"Environment :: Console",
|
|
34
|
+
"Intended Audience :: Developers",
|
|
35
|
+
"Intended Audience :: Science/Research",
|
|
36
|
+
"License :: OSI Approved :: MIT License",
|
|
37
|
+
"Operating System :: OS Independent",
|
|
38
|
+
"Programming Language :: Python :: 3",
|
|
39
|
+
"Programming Language :: Python :: 3.10",
|
|
40
|
+
"Programming Language :: Python :: 3.11",
|
|
41
|
+
"Programming Language :: Python :: 3.12",
|
|
42
|
+
"Programming Language :: Python :: 3.13",
|
|
43
|
+
"Topic :: Scientific/Engineering",
|
|
44
|
+
"Topic :: Software Development :: Quality Assurance",
|
|
45
|
+
"Topic :: Text Processing :: Markup :: LaTeX"
|
|
46
|
+
]
|
|
47
|
+
dependencies = []
|
|
48
|
+
|
|
49
|
+
[project.optional-dependencies]
|
|
50
|
+
dev = ["pytest>=7.4.0"]
|
|
51
|
+
|
|
52
|
+
[project.scripts]
|
|
53
|
+
citeguard-mcp = "citeguard_mcp.cli:main"
|
|
54
|
+
citeguard = "citeguard_mcp.cli:main"
|
|
55
|
+
|
|
56
|
+
[project.urls]
|
|
57
|
+
Homepage = "https://github.com/Lukecele/citeguard-mcp"
|
|
58
|
+
PyPI = "https://pypi.org/project/citeguard-mcp/"
|
|
59
|
+
Repository = "https://github.com/Lukecele/citeguard-mcp"
|
|
60
|
+
Issues = "https://github.com/Lukecele/citeguard-mcp/issues"
|
|
61
|
+
Author = "https://lucacelebrano.me"
|
|
62
|
+
|
|
63
|
+
[tool.setuptools.packages.find]
|
|
64
|
+
where = ["src"]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""CiteGuard MCP — Anti-Hallucination Citation Verification & Literature MCP Server."""
|
|
2
|
+
|
|
3
|
+
__version__ = "0.1.2"
|
|
4
|
+
|
|
5
|
+
from .verifier import (
|
|
6
|
+
verify_citation,
|
|
7
|
+
audit_text,
|
|
8
|
+
search_verified_literature,
|
|
9
|
+
generate_bibtex,
|
|
10
|
+
check_retraction,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"__version__",
|
|
15
|
+
"verify_citation",
|
|
16
|
+
"audit_text",
|
|
17
|
+
"search_verified_literature",
|
|
18
|
+
"generate_bibtex",
|
|
19
|
+
"check_retraction",
|
|
20
|
+
]
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"""Rich Terminal CLI & MCP Server entrypoint for CiteGuard (`citeguard` / `citeguard-mcp`)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
import sys
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from . import __version__
|
|
11
|
+
from .server import run_stdio_server
|
|
12
|
+
from .verifier import (
|
|
13
|
+
audit_text,
|
|
14
|
+
check_retraction,
|
|
15
|
+
generate_bibtex,
|
|
16
|
+
search_verified_literature,
|
|
17
|
+
verify_citation,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
# ANSI Styling
|
|
21
|
+
BOLD = "\033[1m"
|
|
22
|
+
DIM = "\033[2m"
|
|
23
|
+
GREEN = "\033[92m"
|
|
24
|
+
YELLOW = "\033[93m"
|
|
25
|
+
RED = "\033[91m"
|
|
26
|
+
CYAN = "\033[96m"
|
|
27
|
+
MAGENTA = "\033[95m"
|
|
28
|
+
RESET = "\033[0m"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _banner() -> str:
|
|
32
|
+
return (
|
|
33
|
+
f"{CYAN}{BOLD}╭──────────────────────────────────────────────────────────────────────────╮{RESET}\n"
|
|
34
|
+
f"{CYAN}{BOLD}│{RESET} 🛡️ {BOLD}CiteGuard MCP v{__version__}{RESET} — Anti-Hallucination Citation & DOI Verifier {CYAN}{BOLD}│{RESET}\n"
|
|
35
|
+
f"{CYAN}{BOLD}│{RESET} {DIM}Crossref · DataCite/Zenodo · PubMed (NCBI) · OpenAlex · arXiv{RESET} {CYAN}{BOLD}│{RESET}\n"
|
|
36
|
+
f"{CYAN}{BOLD}╰──────────────────────────────────────────────────────────────────────────╯{RESET}"
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _badge(verdict: str) -> str:
|
|
41
|
+
if verdict == "VERIFIED":
|
|
42
|
+
return f"{GREEN}{BOLD}✔ VERIFIED{RESET}"
|
|
43
|
+
if verdict == "CHIMERA_MISMATCH":
|
|
44
|
+
return f"{YELLOW}{BOLD}⚠ CHIMERA MISMATCH{RESET}"
|
|
45
|
+
if verdict == "RETRACTED":
|
|
46
|
+
return f"{MAGENTA}{BOLD}🚨 RETRACTED{RESET}"
|
|
47
|
+
return f"{RED}{BOLD}✘ FABRICATED / 404{RESET}"
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _print_verify_result(res: dict) -> None:
|
|
51
|
+
print(_banner())
|
|
52
|
+
print(f"\n Status : {_badge(res['verdict'])}")
|
|
53
|
+
rec = res.get("record")
|
|
54
|
+
if rec:
|
|
55
|
+
print(f" Registry : {CYAN}{res.get('registry')}{RESET}")
|
|
56
|
+
print(f" Title : {BOLD}{rec.get('title')}{RESET}")
|
|
57
|
+
authors = ", ".join(rec.get("authors", [])[:5])
|
|
58
|
+
if len(rec.get("authors", [])) > 5:
|
|
59
|
+
authors += " et al."
|
|
60
|
+
print(f" Authors : {authors}")
|
|
61
|
+
print(f" Venue : {rec.get('journal')} ({rec.get('year')})")
|
|
62
|
+
if rec.get("doi"):
|
|
63
|
+
print(f" DOI : https://doi.org/{rec['doi']}")
|
|
64
|
+
elif rec.get("url"):
|
|
65
|
+
print(f" URL : {rec['url']}")
|
|
66
|
+
for iss in res.get("issues", []):
|
|
67
|
+
print(f" {RED}▸ {iss}{RESET}")
|
|
68
|
+
if res.get("bibtex"):
|
|
69
|
+
print(f"\n {DIM}── Verified BibTeX ──{RESET}")
|
|
70
|
+
for line in res["bibtex"].splitlines():
|
|
71
|
+
print(f" {CYAN}{line}{RESET}")
|
|
72
|
+
print()
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _print_audit_report(report: dict) -> None:
|
|
76
|
+
print(_banner())
|
|
77
|
+
total = report["total_citations"]
|
|
78
|
+
if total == 0:
|
|
79
|
+
print(f"\n {YELLOW}No citations (DOIs, PMIDs, arXiv IDs, or BibTeX entries) detected.{RESET}\n")
|
|
80
|
+
return
|
|
81
|
+
|
|
82
|
+
score = report["integrity_score"]
|
|
83
|
+
score_color = GREEN if score == 100.0 else (YELLOW if score >= 75.0 else RED)
|
|
84
|
+
print(
|
|
85
|
+
f"\n {BOLD}Citation Integrity Score:{RESET} {score_color}{BOLD}{score:.1f}%{RESET} "
|
|
86
|
+
f"({GREEN}{report['verified_count']} Verified{RESET} · "
|
|
87
|
+
f"{YELLOW}{report['chimera_count']} Chimera{RESET} · "
|
|
88
|
+
f"{RED}{report['fabricated_count']} Fabricated/404{RESET} · "
|
|
89
|
+
f"{MAGENTA}{report['retracted_count']} Retracted{RESET})\n"
|
|
90
|
+
)
|
|
91
|
+
print(f" {DIM}{'─' * 74}{RESET}")
|
|
92
|
+
for idx, r in enumerate(report["results"], 1):
|
|
93
|
+
rec = r.get("record") or {}
|
|
94
|
+
title = rec.get("title") or r.get("query", "")
|
|
95
|
+
if len(title) > 64:
|
|
96
|
+
title = title[:61] + "..."
|
|
97
|
+
reg = f" [{r['registry']}]" if r.get("registry") else ""
|
|
98
|
+
print(f" {BOLD}#{idx:02d}{RESET} {_badge(r['verdict'])}{DIM}{reg}{RESET} — {BOLD}{r.get('source_label')}{RESET}")
|
|
99
|
+
if rec.get("title"):
|
|
100
|
+
yr = rec.get("year") or "n.d."
|
|
101
|
+
auth = (rec.get("authors") or ["Unknown"])[0]
|
|
102
|
+
print(f" {DIM}{auth} ({yr}) · {title}{RESET}")
|
|
103
|
+
for iss in r.get("issues", []):
|
|
104
|
+
print(f" {RED}↳ {iss}{RESET}")
|
|
105
|
+
print(f" {DIM}{'─' * 74}{RESET}\n")
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def main(argv: list[str] | None = None) -> int:
|
|
109
|
+
parser = argparse.ArgumentParser(
|
|
110
|
+
prog="citeguard",
|
|
111
|
+
description="CiteGuard MCP — Anti-Hallucination Citation Verification & Scientific Literature MCP Server.",
|
|
112
|
+
)
|
|
113
|
+
parser.add_argument("--version", action="version", version=f"citeguard-mcp {__version__}")
|
|
114
|
+
sub = parser.add_subparsers(dest="command")
|
|
115
|
+
|
|
116
|
+
# 1. serve (default when run as MCP server)
|
|
117
|
+
sub.add_parser("serve", help="Run the Model Context Protocol (MCP) JSON-RPC 2.0 server over stdio.")
|
|
118
|
+
|
|
119
|
+
# 2. verify
|
|
120
|
+
p_ver = sub.add_parser("verify", help="Verify a single DOI, PMID, arXiv ID, or citation string.")
|
|
121
|
+
p_ver.add_argument("identifier", help="DOI, PMID:xxxx, arXiv:xxxx.xxxxx, or paper title.")
|
|
122
|
+
p_ver.add_argument("--title", help="Claimed title to verify against chimera hallucinations.")
|
|
123
|
+
p_ver.add_argument("--author", help="Claimed author surname to verify.")
|
|
124
|
+
p_ver.add_argument("--year", type=int, help="Claimed publication year to verify.")
|
|
125
|
+
p_ver.add_argument("--json", action="store_true", help="Output raw JSON.")
|
|
126
|
+
|
|
127
|
+
# 3. audit
|
|
128
|
+
p_aud = sub.add_parser("audit", help="Audit all citations in a Markdown, LaTeX, BibTeX, or text file.")
|
|
129
|
+
p_aud.add_argument("file", nargs="?", help="Path to .md, .tex, .bib, or .txt file (or '-' for stdin).")
|
|
130
|
+
p_aud.add_argument("--text", help="Direct text string to audit.")
|
|
131
|
+
p_aud.add_argument("--strict", action="store_true", help="Exit with code 1 if any unverified citation is found.")
|
|
132
|
+
p_aud.add_argument("--json", action="store_true", help="Output raw JSON.")
|
|
133
|
+
|
|
134
|
+
# 4. search
|
|
135
|
+
p_src = sub.add_parser("search", help="Search OpenAlex, PubMed, Crossref & arXiv for verified literature.")
|
|
136
|
+
p_src.add_argument("query", help="Search query.")
|
|
137
|
+
p_src.add_argument("--limit", type=int, default=5, help="Max results (default: 5).")
|
|
138
|
+
p_src.add_argument("--source", choices=["all", "openalex", "pubmed", "arxiv"], default="all")
|
|
139
|
+
p_src.add_argument("--json", action="store_true", help="Output raw JSON.")
|
|
140
|
+
|
|
141
|
+
# 5. bibtex
|
|
142
|
+
p_bib = sub.add_parser("bibtex", help="Generate verified BibTeX entries for one or more DOIs/PMIDs/arXiv IDs.")
|
|
143
|
+
p_bib.add_argument("identifiers", nargs="+", help="One or more DOIs, PMIDs, or arXiv IDs.")
|
|
144
|
+
|
|
145
|
+
# 6. retraction
|
|
146
|
+
p_ret = sub.add_parser("retraction", help="Check if a DOI has been retracted in Crossref or OpenAlex.")
|
|
147
|
+
p_ret.add_argument("doi", help="DOI to check.")
|
|
148
|
+
p_ret.add_argument("--json", action="store_true", help="Output raw JSON.")
|
|
149
|
+
|
|
150
|
+
args = parser.parse_args(argv)
|
|
151
|
+
|
|
152
|
+
# If invoked with no subcommand (e.g. `uvx citeguard-mcp` by Claude Desktop / Cursor / Antigravity):
|
|
153
|
+
if args.command in (None, "serve"):
|
|
154
|
+
if args.command is None and sys.stdin.isatty():
|
|
155
|
+
parser.print_help()
|
|
156
|
+
return 0
|
|
157
|
+
run_stdio_server()
|
|
158
|
+
return 0
|
|
159
|
+
|
|
160
|
+
if args.command == "verify":
|
|
161
|
+
res = verify_citation(
|
|
162
|
+
args.identifier,
|
|
163
|
+
claimed_title=args.title,
|
|
164
|
+
claimed_author=args.author,
|
|
165
|
+
claimed_year=args.year,
|
|
166
|
+
)
|
|
167
|
+
if args.json:
|
|
168
|
+
print(json.dumps(res, indent=2, ensure_ascii=False))
|
|
169
|
+
else:
|
|
170
|
+
_print_verify_result(res)
|
|
171
|
+
return 0 if res["verified"] else 1
|
|
172
|
+
|
|
173
|
+
if args.command == "audit":
|
|
174
|
+
if args.text:
|
|
175
|
+
content = args.text
|
|
176
|
+
elif args.file and args.file != "-":
|
|
177
|
+
content = Path(args.file).read_text(encoding="utf-8", errors="replace")
|
|
178
|
+
else:
|
|
179
|
+
content = sys.stdin.read()
|
|
180
|
+
report = audit_text(content)
|
|
181
|
+
if args.json:
|
|
182
|
+
print(json.dumps(report, indent=2, ensure_ascii=False))
|
|
183
|
+
else:
|
|
184
|
+
_print_audit_report(report)
|
|
185
|
+
if args.strict and (
|
|
186
|
+
report["chimera_count"] > 0 or report["fabricated_count"] > 0 or report["retracted_count"] > 0
|
|
187
|
+
):
|
|
188
|
+
return 1
|
|
189
|
+
return 0
|
|
190
|
+
|
|
191
|
+
if args.command == "search":
|
|
192
|
+
res = search_verified_literature(args.query, limit=args.limit, source=args.source)
|
|
193
|
+
if args.json:
|
|
194
|
+
print(json.dumps(res, indent=2, ensure_ascii=False))
|
|
195
|
+
else:
|
|
196
|
+
print(_banner())
|
|
197
|
+
print(f"\n Found {BOLD}{res['count']}{RESET} verified papers for '{CYAN}{res['query']}{RESET}':\n")
|
|
198
|
+
for idx, r in enumerate(res["results"], 1):
|
|
199
|
+
print(f" {BOLD}[{idx}] {r['title']}{RESET}")
|
|
200
|
+
print(f" {DIM}{r['apa']}{RESET}\n")
|
|
201
|
+
return 0
|
|
202
|
+
|
|
203
|
+
if args.command == "bibtex":
|
|
204
|
+
res = generate_bibtex(args.identifiers)
|
|
205
|
+
print(res["bibtex"])
|
|
206
|
+
return 0 if not res["failed"] else 1
|
|
207
|
+
|
|
208
|
+
if args.command == "retraction":
|
|
209
|
+
res = check_retraction(args.doi)
|
|
210
|
+
if args.json:
|
|
211
|
+
print(json.dumps(res, indent=2, ensure_ascii=False))
|
|
212
|
+
else:
|
|
213
|
+
print(_banner())
|
|
214
|
+
color = MAGENTA if res["is_retracted"] else GREEN
|
|
215
|
+
print(f"\n {color}{BOLD}{res['status']}{RESET}: {res['message']}\n")
|
|
216
|
+
return 1 if res["is_retracted"] else 0
|
|
217
|
+
|
|
218
|
+
return 0
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
if __name__ == "__main__":
|
|
222
|
+
raise SystemExit(main())
|