sourceatlas-mcp 0.1.0__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ahmed Saeed
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,3 @@
1
+ include LICENSE README.md THIRD_PARTY.md server.json
2
+ recursive-include assets *.svg
3
+ recursive-include tests *.py
@@ -0,0 +1,161 @@
1
+ Metadata-Version: 2.4
2
+ Name: sourceatlas-mcp
3
+ Version: 0.1.0
4
+ Summary: Offline MCP evidence organizer for supplied public-source records
5
+ License-Expression: MIT
6
+ Project-URL: Repository, https://github.com/ahmedsaeed1-eng/sourceatlas-mcp
7
+ Project-URL: Issues, https://github.com/ahmedsaeed1-eng/sourceatlas-mcp/issues
8
+ Keywords: mcp,research,citations,metadata
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: mcp<2,>=1.29
13
+ Dynamic: license-file
14
+
15
+ <img align="right" src="assets/logo.svg" width="190" alt="SourceAtlas catalog mark">
16
+
17
+ # SourceAtlas MCP
18
+
19
+ <!-- mcp-name: io.github.ahmedsaeed1-eng/sourceatlas-mcp -->
20
+
21
+ ### The evidence desk
22
+
23
+ A local research companion for organizing the references already in your hands.
24
+
25
+ | Catalog entry | Details |
26
+ | :--- | :--- |
27
+ | Edition | 0.1.0 |
28
+ | Interface | MCP over stdio |
29
+ | Storage | In-memory; no persistent dossier |
30
+ | Scope | Caller-provided public-source metadata |
31
+ | Verification | Formatting and metadata only |
32
+
33
+ [![License: MIT](https://img.shields.io/badge/License-MIT-8a5a32?style=flat)](LICENSE) [![Runtime: offline](https://img.shields.io/badge/Runtime-offline-377466?style=flat)](#provenance-and-boundaries) [![Repository stars](https://img.shields.io/github/stars/ahmedsaeed1-eng/sourceatlas-mcp?style=flat&color=b07a43)](https://github.com/ahmedsaeed1-eng/sourceatlas-mcp/stargazers) [![CI](https://github.com/ahmedsaeed1-eng/sourceatlas-mcp/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/ahmedsaeed1-eng/sourceatlas-mcp/actions/workflows/ci.yml)
34
+
35
+ ---
36
+
37
+ SourceAtlas turns public-source metadata you already possess into organized research
38
+ notes. It validates identifier syntax, detects duplicates and conflicting metadata,
39
+ flags age and missing fields, and drafts citations and evidence tables. No web
40
+ retrieval, browser connection, authentication, or source verification is performed.
41
+
42
+ ## Open your workspace
43
+
44
+ Use Python 3.10 or newer in a virtual environment. Dependency installation requires
45
+ package access; the server itself processes metadata locally.
46
+
47
+ ```bash
48
+ git clone https://github.com/ahmedsaeed1-eng/sourceatlas-mcp.git
49
+ cd sourceatlas-mcp
50
+ python -m venv .venv
51
+ # Activate the virtual environment for your OS.
52
+ python -m pip install .
53
+ python -m sourceatlas_mcp
54
+ ```
55
+
56
+ The final command launches an MCP server over stdio. It waits for protocol messages;
57
+ it does not display an interactive terminal interface.
58
+
59
+ Configure an MCP-compatible client with an absolute path to the Python executable
60
+ in the environment where the package is installed. Adapt this generic stdio
61
+ example to your client's format:
62
+
63
+ ```json
64
+ {
65
+ "mcpServers": {
66
+ "sourceatlas": {
67
+ "command": "/absolute/path/to/venv/bin/python",
68
+ "args": ["-m", "sourceatlas_mcp"]
69
+ }
70
+ }
71
+ }
72
+ ```
73
+
74
+ On Windows, use the virtual environment's `.venv\Scripts\python.exe` path and
75
+ escape backslashes in JSON.
76
+
77
+ ## Evidence desk · catalog tools
78
+
79
+ | Tool | Input | Output |
80
+ | --- | --- | --- |
81
+ | `normalize_source` | one record | normalized URL/DOI and validated fields |
82
+ | `group_sources` | 1–100 records | unique groups, conflicting values, member indexes |
83
+ | `format_citation` | one record | plain-language draft citation |
84
+ | `check_recency` | records, reference date, max age | recency statuses and missing metadata |
85
+ | `build_evidence_table` | records | Markdown evidence inventory |
86
+
87
+ Each record requires a title and at least one URL or DOI.
88
+ Optional fields: `publisher`, `published` (YYYY-MM-DD), `kind` (primary,
89
+ secondary, tertiary, unknown), `claim`, and `summary`.
90
+ Unknown fields are rejected. Strings are bounded and control characters rejected.
91
+
92
+ ## Reference card · example
93
+
94
+ Pass an array of record objects to `group_sources`:
95
+
96
+ ```json
97
+ [
98
+ {
99
+ "title": "Example public report",
100
+ "url": "https://example.org/report?id=1&utm_source=newsletter#top",
101
+ "publisher": "Example publisher",
102
+ "published": "2024-01-01",
103
+ "kind": "primary"
104
+ },
105
+ {
106
+ "title": "Example public report",
107
+ "url": "https://EXAMPLE.org:443/report?id=1",
108
+ "published": "2024-01-02"
109
+ }
110
+ ]
111
+ ```
112
+
113
+ These illustrative records group together because the normalized URLs match.
114
+ The differing publication dates are preserved as a conflict. SourceAtlas keeps
115
+ the first supplied nonempty value for display and reports all distinct
116
+ conflicting values. Input positions are zero-based. A record sharing both a
117
+ DOI and URL can connect groups; conflicting identifiers are explicitly reported.
118
+
119
+ The reference-date check classifies records as recent, stale, missing, future or
120
+ conflicting. The threshold is inclusive; the default is 365 days. It does not
121
+ estimate credibility or validate a publisher's reputation.
122
+
123
+ ## Provenance and boundaries
124
+
125
+ - No HTTP requests, browser automation, account access, cookies or source downloads.
126
+ - URL normalization is only for grouping identity. It lowercases scheme/host,
127
+ strips default port, fragment, and common tracking parameters; query fields
128
+ are decoded and re-encoded in existing order; invalid UTF-8 query escapes are rejected. It does not establish that a
129
+ domain resolves to a public address, and is not a security URL validator.
130
+ - DOI validation checks common DOI syntax only. Neither references nor claims
131
+ are verified. Draft citations are not compliance guarantees for formal styles.
132
+ - No storage, background research, external services, or automatic publication.
133
+ - Metadata is untrusted text; Markdown table delimiters and markup are escaped.
134
+ Do not submit private records, access tokens, or signed URLs.
135
+
136
+ ## Validation checklist
137
+
138
+ ```bash
139
+ python -m unittest discover -s tests -v
140
+ ```
141
+
142
+ The suite covers URL/DOI normalization, connected duplicate groups, conflicts,
143
+ invalid input, recency, Markdown escaping, and a real stdio MCP client session
144
+ exercising all five tools. CI is configured for Linux, Windows and macOS.
145
+
146
+ ## License
147
+
148
+ MIT. See [LICENSE](LICENSE) and [third-party credits](THIRD_PARTY.md).
149
+ This project is independent and does not incorporate Agent Reach source code.
150
+
151
+ ## Distribution and MCP launch
152
+
153
+ After installation, `sourceatlas-mcp` starts the same stdio MCP server as the module invocation above.
154
+ Once the version is published to PyPI, an MCP client with `uvx` can launch it using:
155
+
156
+ ```sh
157
+ uvx sourceatlas-mcp==0.1.0
158
+ ```
159
+
160
+ This repository contains registry metadata and a manually dispatched packaging workflow.
161
+ Package and MCP registry publication are separate steps; the metadata alone does not publish them.
@@ -0,0 +1,147 @@
1
+ <img align="right" src="assets/logo.svg" width="190" alt="SourceAtlas catalog mark">
2
+
3
+ # SourceAtlas MCP
4
+
5
+ <!-- mcp-name: io.github.ahmedsaeed1-eng/sourceatlas-mcp -->
6
+
7
+ ### The evidence desk
8
+
9
+ A local research companion for organizing the references already in your hands.
10
+
11
+ | Catalog entry | Details |
12
+ | :--- | :--- |
13
+ | Edition | 0.1.0 |
14
+ | Interface | MCP over stdio |
15
+ | Storage | In-memory; no persistent dossier |
16
+ | Scope | Caller-provided public-source metadata |
17
+ | Verification | Formatting and metadata only |
18
+
19
+ [![License: MIT](https://img.shields.io/badge/License-MIT-8a5a32?style=flat)](LICENSE) [![Runtime: offline](https://img.shields.io/badge/Runtime-offline-377466?style=flat)](#provenance-and-boundaries) [![Repository stars](https://img.shields.io/github/stars/ahmedsaeed1-eng/sourceatlas-mcp?style=flat&color=b07a43)](https://github.com/ahmedsaeed1-eng/sourceatlas-mcp/stargazers) [![CI](https://github.com/ahmedsaeed1-eng/sourceatlas-mcp/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/ahmedsaeed1-eng/sourceatlas-mcp/actions/workflows/ci.yml)
20
+
21
+ ---
22
+
23
+ SourceAtlas turns public-source metadata you already possess into organized research
24
+ notes. It validates identifier syntax, detects duplicates and conflicting metadata,
25
+ flags age and missing fields, and drafts citations and evidence tables. No web
26
+ retrieval, browser connection, authentication, or source verification is performed.
27
+
28
+ ## Open your workspace
29
+
30
+ Use Python 3.10 or newer in a virtual environment. Dependency installation requires
31
+ package access; the server itself processes metadata locally.
32
+
33
+ ```bash
34
+ git clone https://github.com/ahmedsaeed1-eng/sourceatlas-mcp.git
35
+ cd sourceatlas-mcp
36
+ python -m venv .venv
37
+ # Activate the virtual environment for your OS.
38
+ python -m pip install .
39
+ python -m sourceatlas_mcp
40
+ ```
41
+
42
+ The final command launches an MCP server over stdio. It waits for protocol messages;
43
+ it does not display an interactive terminal interface.
44
+
45
+ Configure an MCP-compatible client with an absolute path to the Python executable
46
+ in the environment where the package is installed. Adapt this generic stdio
47
+ example to your client's format:
48
+
49
+ ```json
50
+ {
51
+ "mcpServers": {
52
+ "sourceatlas": {
53
+ "command": "/absolute/path/to/venv/bin/python",
54
+ "args": ["-m", "sourceatlas_mcp"]
55
+ }
56
+ }
57
+ }
58
+ ```
59
+
60
+ On Windows, use the virtual environment's `.venv\Scripts\python.exe` path and
61
+ escape backslashes in JSON.
62
+
63
+ ## Evidence desk · catalog tools
64
+
65
+ | Tool | Input | Output |
66
+ | --- | --- | --- |
67
+ | `normalize_source` | one record | normalized URL/DOI and validated fields |
68
+ | `group_sources` | 1–100 records | unique groups, conflicting values, member indexes |
69
+ | `format_citation` | one record | plain-language draft citation |
70
+ | `check_recency` | records, reference date, max age | recency statuses and missing metadata |
71
+ | `build_evidence_table` | records | Markdown evidence inventory |
72
+
73
+ Each record requires a title and at least one URL or DOI.
74
+ Optional fields: `publisher`, `published` (YYYY-MM-DD), `kind` (primary,
75
+ secondary, tertiary, unknown), `claim`, and `summary`.
76
+ Unknown fields are rejected. Strings are bounded and control characters rejected.
77
+
78
+ ## Reference card · example
79
+
80
+ Pass an array of record objects to `group_sources`:
81
+
82
+ ```json
83
+ [
84
+ {
85
+ "title": "Example public report",
86
+ "url": "https://example.org/report?id=1&utm_source=newsletter#top",
87
+ "publisher": "Example publisher",
88
+ "published": "2024-01-01",
89
+ "kind": "primary"
90
+ },
91
+ {
92
+ "title": "Example public report",
93
+ "url": "https://EXAMPLE.org:443/report?id=1",
94
+ "published": "2024-01-02"
95
+ }
96
+ ]
97
+ ```
98
+
99
+ These illustrative records group together because the normalized URLs match.
100
+ The differing publication dates are preserved as a conflict. SourceAtlas keeps
101
+ the first supplied nonempty value for display and reports all distinct
102
+ conflicting values. Input positions are zero-based. A record sharing both a
103
+ DOI and URL can connect groups; conflicting identifiers are explicitly reported.
104
+
105
+ The reference-date check classifies records as recent, stale, missing, future or
106
+ conflicting. The threshold is inclusive; the default is 365 days. It does not
107
+ estimate credibility or validate a publisher's reputation.
108
+
109
+ ## Provenance and boundaries
110
+
111
+ - No HTTP requests, browser automation, account access, cookies or source downloads.
112
+ - URL normalization is only for grouping identity. It lowercases scheme/host,
113
+ strips default port, fragment, and common tracking parameters; query fields
114
+ are decoded and re-encoded in existing order; invalid UTF-8 query escapes are rejected. It does not establish that a
115
+ domain resolves to a public address, and is not a security URL validator.
116
+ - DOI validation checks common DOI syntax only. Neither references nor claims
117
+ are verified. Draft citations are not compliance guarantees for formal styles.
118
+ - No storage, background research, external services, or automatic publication.
119
+ - Metadata is untrusted text; Markdown table delimiters and markup are escaped.
120
+ Do not submit private records, access tokens, or signed URLs.
121
+
122
+ ## Validation checklist
123
+
124
+ ```bash
125
+ python -m unittest discover -s tests -v
126
+ ```
127
+
128
+ The suite covers URL/DOI normalization, connected duplicate groups, conflicts,
129
+ invalid input, recency, Markdown escaping, and a real stdio MCP client session
130
+ exercising all five tools. CI is configured for Linux, Windows and macOS.
131
+
132
+ ## License
133
+
134
+ MIT. See [LICENSE](LICENSE) and [third-party credits](THIRD_PARTY.md).
135
+ This project is independent and does not incorporate Agent Reach source code.
136
+
137
+ ## Distribution and MCP launch
138
+
139
+ After installation, `sourceatlas-mcp` starts the same stdio MCP server as the module invocation above.
140
+ Once the version is published to PyPI, an MCP client with `uvx` can launch it using:
141
+
142
+ ```sh
143
+ uvx sourceatlas-mcp==0.1.0
144
+ ```
145
+
146
+ This repository contains registry metadata and a manually dispatched packaging workflow.
147
+ Package and MCP registry publication are separate steps; the metadata alone does not publish them.
@@ -0,0 +1,4 @@
1
+ SourceAtlas is an independently implemented project. Its sole direct dependency is
2
+ the official [Model Context Protocol Python SDK](https://github.com/modelcontextprotocol/python-sdk),
3
+ distributed under the MIT license. Transitive dependencies retain their respective licenses.
4
+ SourceAtlas does not include code from Agent Reach or other referenced research tools.
@@ -0,0 +1,13 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 250" role="img" aria-labelledby="title">
2
+ <title id="title">SourceAtlas library catalog</title>
3
+ <rect x="12" y="12" width="216" height="226" rx="12" fill="#254f47"/>
4
+ <rect x="35" y="37" width="170" height="183" rx="5" fill="#d6c3a2" transform="rotate(-7 120 125)"/>
5
+ <rect x="43" y="31" width="164" height="185" rx="5" fill="#fff6e1" stroke="#b8996f" stroke-width="2"/>
6
+ <path d="M55 94H194M55 143H194M55 166H194" stroke="#ac9776" stroke-width="1.5"/>
7
+ <text x="58" y="51" font-family="monospace" font-size="10" fill="#836747">FIELD NOTES / 001</text>
8
+ <text x="58" y="82" font-family="serif" font-weight="bold" font-size="22" fill="#254f47">SourceAtlas</text>
9
+ <text x="58" y="111" font-family="monospace" font-size="9" fill="#836747">PUBLIC REFERENCES</text>
10
+ <path d="M58 124h110M58 133h83M58 155h79M58 178h116M58 187h94" fill="none" stroke="#627a6b" stroke-width="3" stroke-linecap="round"/>
11
+ <circle cx="185" cy="199" r="20" fill="#9d5f38"/>
12
+ <path d="m175 199 7 6 13-14" fill="none" stroke="#fff6e1" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
13
+ </svg>
@@ -0,0 +1,24 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "sourceatlas-mcp"
7
+ version = "0.1.0"
8
+ description = "Offline MCP evidence organizer for supplied public-source records"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ dependencies = ["mcp>=1.29,<2"]
14
+ keywords = ["mcp", "research", "citations", "metadata"]
15
+
16
+ [project.scripts]
17
+ sourceatlas-mcp = "sourceatlas_mcp.__main__:main"
18
+
19
+ [project.urls]
20
+ Repository = "https://github.com/ahmedsaeed1-eng/sourceatlas-mcp"
21
+ Issues = "https://github.com/ahmedsaeed1-eng/sourceatlas-mcp/issues"
22
+
23
+ [tool.setuptools.packages.find]
24
+ include = ["sourceatlas_mcp*"]
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.ahmedsaeed1-eng/sourceatlas-mcp",
4
+ "title": "SourceAtlas MCP",
5
+ "description": "Offline evidence organizer for supplied public-source metadata",
6
+ "repository": {
7
+ "url": "https://github.com/ahmedsaeed1-eng/sourceatlas-mcp",
8
+ "source": "github"
9
+ },
10
+ "version": "0.1.0",
11
+ "packages": [
12
+ {
13
+ "registryType": "pypi",
14
+ "registryBaseUrl": "https://pypi.org",
15
+ "identifier": "sourceatlas-mcp",
16
+ "version": "0.1.0",
17
+ "runtimeHint": "uvx",
18
+ "transport": {
19
+ "type": "stdio"
20
+ }
21
+ }
22
+ ]
23
+ }
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,2 @@
1
+ """SourceAtlas MCP — offline evidence organization."""
2
+ __version__ = "0.1.0"
@@ -0,0 +1,35 @@
1
+ from mcp.server.fastmcp import FastMCP
2
+ from .core import normalize_record, organize, citation, recency, evidence_table
3
+
4
+ mcp = FastMCP("SourceAtlas", instructions="Organize metadata for explicitly caller-supplied public research records. Never retrieves, verifies, or searches the web; do not mistake formatting for factual verification.")
5
+
6
+ @mcp.tool()
7
+ def normalize_source(record: dict) -> dict:
8
+ """Normalize a supplied source URL or DOI and validate metadata syntax without network access."""
9
+ return normalize_record(record)
10
+
11
+ @mcp.tool()
12
+ def group_sources(records: list[dict]) -> dict:
13
+ """Identify duplicate sources by supplied DOI and normalized URL; show metadata conflicts and input indexes."""
14
+ return organize(records)
15
+
16
+ @mcp.tool()
17
+ def format_citation(record: dict) -> str:
18
+ """Create a plain-language draft citation from supplied source metadata."""
19
+ return citation(record)
20
+
21
+ @mcp.tool()
22
+ def check_recency(records: list[dict], as_of: str, max_age_days: int = 365) -> dict:
23
+ """Report date age, missing metadata and conflicts for a caller-supplied YYYY-MM-DD reference date."""
24
+ return recency(records, as_of, max_age_days)
25
+
26
+ @mcp.tool()
27
+ def build_evidence_table(records: list[dict]) -> str:
28
+ """Render a Markdown inventory of deduplicated caller-supplied public sources and conflicts."""
29
+ return evidence_table(records)
30
+
31
+ def main():
32
+ mcp.run(transport="stdio")
33
+
34
+ if __name__ == "__main__":
35
+ main()
@@ -0,0 +1,154 @@
1
+ """Deterministic, offline organization for explicitly supplied public sources."""
2
+ from datetime import date
3
+ from urllib.parse import urlsplit, urlunsplit, parse_qsl, urlencode
4
+ import ipaddress
5
+ import re
6
+
7
+ MAX_RECORDS = 100
8
+ TEXT_LIMIT = 2000
9
+ DOI = re.compile(r"10\.\d{4,9}/[^\s]+", re.I)
10
+ TRACKING = {"fbclid","gclid","mc_cid","mc_eid"}
11
+ KINDS = {"primary","secondary","tertiary","unknown"}
12
+
13
+ def clean(value: str, name: str, limit: int = TEXT_LIMIT) -> str:
14
+ if not isinstance(value, str):
15
+ raise ValueError(f"{name} must be text")
16
+ if any(ord(c) < 32 or ord(c) == 127 for c in value):
17
+ raise ValueError(f"{name} contains control characters")
18
+ value = " ".join(value.split())
19
+ if len(value) > limit:
20
+ raise ValueError(f"{name} exceeds {limit} characters")
21
+ return value
22
+
23
+ def normalize_url(value: str) -> str:
24
+ """Identity normalization only; does not resolve or visit a location."""
25
+ if not isinstance(value, str):
26
+ raise ValueError("URL must be text")
27
+ if re.search(r"%(?![0-9a-fA-F]{2})", value):
28
+ raise ValueError("Malformed percent escape")
29
+ if len(value) > 2048 or any(c.isspace() or ord(c) < 32 or ord(c) == 127 for c in value) or "\\" in value:
30
+ raise ValueError("Invalid URL whitespace, size, or control characters")
31
+ try:
32
+ p = urlsplit(value)
33
+ if p.scheme.lower() not in ("http","https") or p.username is not None or p.password is not None or not p.hostname:
34
+ raise ValueError("URL must be HTTP(S), public hostname, and contain no credentials")
35
+ host = p.hostname.encode("idna").decode("ascii").lower().rstrip(".")
36
+ try:
37
+ ipaddress.ip_address(host)
38
+ except ValueError:
39
+ pass
40
+ else:
41
+ raise ValueError("Numeric hosts are not supported")
42
+ if "." not in host or host.endswith((".local",".localhost",".internal",".test",".invalid",".example")) or not all(re.fullmatch(r"[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?", x) for x in host.split(".")):
43
+ raise ValueError("A public-style domain name is required")
44
+ port = p.port
45
+ if port not in (None, 80 if p.scheme.lower() == "http" else 443):
46
+ raise ValueError("Nonstandard ports are not supported")
47
+ query = urlencode([(k,v) for k,v in parse_qsl(p.query, keep_blank_values=True, max_num_fields=100, errors="strict") if not k.casefold().startswith("utm_") and k.casefold() not in TRACKING])
48
+ return urlunsplit((p.scheme.lower(),host,p.path or "/",query,""))
49
+ except (UnicodeError, ValueError) as e:
50
+ raise ValueError(str(e)) from None
51
+
52
+ def normalize_doi(value: str) -> str:
53
+ value = clean(value,"doi",512)
54
+ if value.lower().startswith("doi:"):
55
+ value = value[4:].strip()
56
+ elif value.lower().startswith("https://doi.org/"):
57
+ value = value[16:]
58
+ if not DOI.fullmatch(value):
59
+ raise ValueError("Invalid DOI syntax")
60
+ return value.lower()
61
+
62
+ def parse_date(value: str) -> date:
63
+ if not isinstance(value, str) or not re.fullmatch(r"\d{4}-\d{2}-\d{2}", value):
64
+ raise ValueError("Use a calendar date YYYY-MM-DD")
65
+ return date.fromisoformat(value)
66
+
67
+ def normalize_record(record: dict) -> dict:
68
+ if not isinstance(record,dict):
69
+ raise ValueError("Each record must be an object")
70
+ unknown = set(record) - {"title","url","doi","publisher","published","kind","summary","claim"}
71
+ if unknown:
72
+ raise ValueError("Unknown fields: " + ", ".join(sorted(unknown)))
73
+ result = {key:clean(record.get(key,""),key,512 if key in ("title","publisher","claim") else TEXT_LIMIT) for key in ("title","publisher","summary","claim")}
74
+ if not result["title"]:
75
+ raise ValueError("Source title required")
76
+ result["url"] = normalize_url(record["url"]) if record.get("url") not in (None, "") else ""
77
+ result["doi"] = normalize_doi(record["doi"]) if record.get("doi") not in (None, "") else ""
78
+ if not (result["url"] or result["doi"]):
79
+ raise ValueError("URL or DOI required")
80
+ if result["url"].startswith("https://doi.org/"):
81
+ implied = normalize_doi(result["url"])
82
+ if result["doi"] and result["doi"] != implied:
83
+ raise ValueError("DOI conflicts with the DOI URL")
84
+ result["doi"] = implied
85
+ result["published"] = parse_date(record["published"]).isoformat() if record.get("published") not in (None, "") else ""
86
+ result["kind"] = clean(record.get("kind","unknown"),"kind",32).lower()
87
+ if result["kind"] not in KINDS:
88
+ raise ValueError("kind must be primary, secondary, tertiary, or unknown")
89
+ return result
90
+
91
+ def organize(records: list[dict]) -> dict:
92
+ if not isinstance(records,list) or not 1 <= len(records) <= MAX_RECORDS:
93
+ raise ValueError("Provide 1–100 source records")
94
+ normalized = [normalize_record(r) for r in records]
95
+ # Connected components capture bridging records sharing a DOI or URL.
96
+ roots = list(range(len(normalized)))
97
+ def root(i):
98
+ while roots[i] != i:
99
+ i=roots[i]
100
+ return i
101
+ ids={}
102
+ for i,r in enumerate(normalized):
103
+ for key in ("doi","url"):
104
+ if not r[key]: continue
105
+ t=(key,r[key])
106
+ if t in ids:
107
+ a,b=root(i),root(ids[t])
108
+ roots[max(a,b)]=min(a,b)
109
+ ids[t]=i
110
+ groups={}
111
+ for i,r in enumerate(normalized):
112
+ groups.setdefault(root(i),[]).append((i,r))
113
+ output=[]
114
+ for members in groups.values():
115
+ fields = {}
116
+ conflicts={}
117
+ for field in normalized[0]:
118
+ values=list(dict.fromkeys(r[field] for _,r in members if r[field] and (field!="kind" or r[field]!="unknown")))
119
+ fields[field]=values[0] if values else ("unknown" if field=="kind" else "")
120
+ if len(values)>1: conflicts[field]=values
121
+ output.append({"record":fields,"member_indexes":[i for i,_ in members],"conflicts":conflicts})
122
+ return {"input_count":len(records),"unique_count":len(output),"duplicate_count":len(records)-len(output),"groups":output,"verification":"Metadata supplied by caller; no source was retrieved or fact-checked."}
123
+
124
+ def citation(record: dict) -> str:
125
+ r=normalize_record(record)
126
+ return f"{r['title']}. {r['publisher'] or 'Publisher not supplied'}. {r['published'] or 'Date not supplied'}. {('https://doi.org/'+r['doi']) if r['doi'] else r['url']}"
127
+
128
+ def recency(records: list[dict], as_of: str, max_age_days: int=365) -> dict:
129
+ if not isinstance(max_age_days,int) or isinstance(max_age_days,bool) or not 1 <= max_age_days <= 36500:
130
+ raise ValueError("max_age_days must be 1–36500")
131
+ today=parse_date(as_of)
132
+ result=organize(records)
133
+ items=[]
134
+ for group in result["groups"]:
135
+ r=group["record"]
136
+ age=(today-parse_date(r["published"])).days if r["published"] else None
137
+ status="conflicting" if "published" in group["conflicts"] else "missing" if age is None else "future" if age<0 else "stale" if age>max_age_days else "recent"
138
+ gaps=[key for key in ("publisher","published","summary","claim") if not r[key]]
139
+ if r["kind"]=="unknown": gaps.append("kind")
140
+ items.append({"title":r["title"],"age_days":age,"recency":status,"missing_metadata":gaps,"metadata_conflicts":list(group["conflicts"])})
141
+ return {"as_of":as_of,"max_age_days":max_age_days,"items":items,"note":"Recency and completeness do not establish credibility or prove claims."}
142
+
143
+ def md(value: str) -> str:
144
+ # Prevent caller-supplied text from becoming Markdown or HTML.
145
+ return "".join("&#"+str(ord(c))+";" if c in "&<>|[]()*_`!#\\~" else c for c in value)
146
+
147
+ def evidence_table(records: list[dict]) -> str:
148
+ result=organize(records)
149
+ lines=["# Evidence inventory","","Caller-supplied metadata only; sources were not retrieved or verified.","","| Source | Publisher | Date | Type | Claim | Summary | Identifier | Conflicts |","| --- | --- | --- | --- | --- | --- | --- | --- |"]
150
+ for group in result["groups"]:
151
+ r=group["record"]
152
+ values=[r["title"],r["publisher"],r["published"],r["kind"],r["claim"],r["summary"],r["doi"] or r["url"],", ".join(group["conflicts"])]
153
+ lines.append("| "+" | ".join(md(v) if v else "Not supplied" for v in values)+" |")
154
+ return "\n".join(lines)+"\n"
@@ -0,0 +1,161 @@
1
+ Metadata-Version: 2.4
2
+ Name: sourceatlas-mcp
3
+ Version: 0.1.0
4
+ Summary: Offline MCP evidence organizer for supplied public-source records
5
+ License-Expression: MIT
6
+ Project-URL: Repository, https://github.com/ahmedsaeed1-eng/sourceatlas-mcp
7
+ Project-URL: Issues, https://github.com/ahmedsaeed1-eng/sourceatlas-mcp/issues
8
+ Keywords: mcp,research,citations,metadata
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: mcp<2,>=1.29
13
+ Dynamic: license-file
14
+
15
+ <img align="right" src="assets/logo.svg" width="190" alt="SourceAtlas catalog mark">
16
+
17
+ # SourceAtlas MCP
18
+
19
+ <!-- mcp-name: io.github.ahmedsaeed1-eng/sourceatlas-mcp -->
20
+
21
+ ### The evidence desk
22
+
23
+ A local research companion for organizing the references already in your hands.
24
+
25
+ | Catalog entry | Details |
26
+ | :--- | :--- |
27
+ | Edition | 0.1.0 |
28
+ | Interface | MCP over stdio |
29
+ | Storage | In-memory; no persistent dossier |
30
+ | Scope | Caller-provided public-source metadata |
31
+ | Verification | Formatting and metadata only |
32
+
33
+ [![License: MIT](https://img.shields.io/badge/License-MIT-8a5a32?style=flat)](LICENSE) [![Runtime: offline](https://img.shields.io/badge/Runtime-offline-377466?style=flat)](#provenance-and-boundaries) [![Repository stars](https://img.shields.io/github/stars/ahmedsaeed1-eng/sourceatlas-mcp?style=flat&color=b07a43)](https://github.com/ahmedsaeed1-eng/sourceatlas-mcp/stargazers) [![CI](https://github.com/ahmedsaeed1-eng/sourceatlas-mcp/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/ahmedsaeed1-eng/sourceatlas-mcp/actions/workflows/ci.yml)
34
+
35
+ ---
36
+
37
+ SourceAtlas turns public-source metadata you already possess into organized research
38
+ notes. It validates identifier syntax, detects duplicates and conflicting metadata,
39
+ flags age and missing fields, and drafts citations and evidence tables. No web
40
+ retrieval, browser connection, authentication, or source verification is performed.
41
+
42
+ ## Open your workspace
43
+
44
+ Use Python 3.10 or newer in a virtual environment. Dependency installation requires
45
+ package access; the server itself processes metadata locally.
46
+
47
+ ```bash
48
+ git clone https://github.com/ahmedsaeed1-eng/sourceatlas-mcp.git
49
+ cd sourceatlas-mcp
50
+ python -m venv .venv
51
+ # Activate the virtual environment for your OS.
52
+ python -m pip install .
53
+ python -m sourceatlas_mcp
54
+ ```
55
+
56
+ The final command launches an MCP server over stdio. It waits for protocol messages;
57
+ it does not display an interactive terminal interface.
58
+
59
+ Configure an MCP-compatible client with an absolute path to the Python executable
60
+ in the environment where the package is installed. Adapt this generic stdio
61
+ example to your client's format:
62
+
63
+ ```json
64
+ {
65
+ "mcpServers": {
66
+ "sourceatlas": {
67
+ "command": "/absolute/path/to/venv/bin/python",
68
+ "args": ["-m", "sourceatlas_mcp"]
69
+ }
70
+ }
71
+ }
72
+ ```
73
+
74
+ On Windows, use the virtual environment's `.venv\Scripts\python.exe` path and
75
+ escape backslashes in JSON.
76
+
77
+ ## Evidence desk · catalog tools
78
+
79
+ | Tool | Input | Output |
80
+ | --- | --- | --- |
81
+ | `normalize_source` | one record | normalized URL/DOI and validated fields |
82
+ | `group_sources` | 1–100 records | unique groups, conflicting values, member indexes |
83
+ | `format_citation` | one record | plain-language draft citation |
84
+ | `check_recency` | records, reference date, max age | recency statuses and missing metadata |
85
+ | `build_evidence_table` | records | Markdown evidence inventory |
86
+
87
+ Each record requires a title and at least one URL or DOI.
88
+ Optional fields: `publisher`, `published` (YYYY-MM-DD), `kind` (primary,
89
+ secondary, tertiary, unknown), `claim`, and `summary`.
90
+ Unknown fields are rejected. Strings are bounded and control characters rejected.
91
+
92
+ ## Reference card · example
93
+
94
+ Pass an array of record objects to `group_sources`:
95
+
96
+ ```json
97
+ [
98
+ {
99
+ "title": "Example public report",
100
+ "url": "https://example.org/report?id=1&utm_source=newsletter#top",
101
+ "publisher": "Example publisher",
102
+ "published": "2024-01-01",
103
+ "kind": "primary"
104
+ },
105
+ {
106
+ "title": "Example public report",
107
+ "url": "https://EXAMPLE.org:443/report?id=1",
108
+ "published": "2024-01-02"
109
+ }
110
+ ]
111
+ ```
112
+
113
+ These illustrative records group together because the normalized URLs match.
114
+ The differing publication dates are preserved as a conflict. SourceAtlas keeps
115
+ the first supplied nonempty value for display and reports all distinct
116
+ conflicting values. Input positions are zero-based. A record sharing both a
117
+ DOI and URL can connect groups; conflicting identifiers are explicitly reported.
118
+
119
+ The reference-date check classifies records as recent, stale, missing, future or
120
+ conflicting. The threshold is inclusive; the default is 365 days. It does not
121
+ estimate credibility or validate a publisher's reputation.
122
+
123
+ ## Provenance and boundaries
124
+
125
+ - No HTTP requests, browser automation, account access, cookies or source downloads.
126
+ - URL normalization is only for grouping identity. It lowercases scheme/host,
127
+ strips default port, fragment, and common tracking parameters; query fields
128
+ are decoded and re-encoded in existing order; invalid UTF-8 query escapes are rejected. It does not establish that a
129
+ domain resolves to a public address, and is not a security URL validator.
130
+ - DOI validation checks common DOI syntax only. Neither references nor claims
131
+ are verified. Draft citations are not compliance guarantees for formal styles.
132
+ - No storage, background research, external services, or automatic publication.
133
+ - Metadata is untrusted text; Markdown table delimiters and markup are escaped.
134
+ Do not submit private records, access tokens, or signed URLs.
135
+
136
+ ## Validation checklist
137
+
138
+ ```bash
139
+ python -m unittest discover -s tests -v
140
+ ```
141
+
142
+ The suite covers URL/DOI normalization, connected duplicate groups, conflicts,
143
+ invalid input, recency, Markdown escaping, and a real stdio MCP client session
144
+ exercising all five tools. CI is configured for Linux, Windows and macOS.
145
+
146
+ ## License
147
+
148
+ MIT. See [LICENSE](LICENSE) and [third-party credits](THIRD_PARTY.md).
149
+ This project is independent and does not incorporate Agent Reach source code.
150
+
151
+ ## Distribution and MCP launch
152
+
153
+ After installation, `sourceatlas-mcp` starts the same stdio MCP server as the module invocation above.
154
+ Once the version is published to PyPI, an MCP client with `uvx` can launch it using:
155
+
156
+ ```sh
157
+ uvx sourceatlas-mcp==0.1.0
158
+ ```
159
+
160
+ This repository contains registry metadata and a manually dispatched packaging workflow.
161
+ Package and MCP registry publication are separate steps; the metadata alone does not publish them.
@@ -0,0 +1,18 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ THIRD_PARTY.md
5
+ pyproject.toml
6
+ server.json
7
+ assets/logo.svg
8
+ sourceatlas_mcp/__init__.py
9
+ sourceatlas_mcp/__main__.py
10
+ sourceatlas_mcp/core.py
11
+ sourceatlas_mcp.egg-info/PKG-INFO
12
+ sourceatlas_mcp.egg-info/SOURCES.txt
13
+ sourceatlas_mcp.egg-info/dependency_links.txt
14
+ sourceatlas_mcp.egg-info/entry_points.txt
15
+ sourceatlas_mcp.egg-info/requires.txt
16
+ sourceatlas_mcp.egg-info/top_level.txt
17
+ tests/test_core.py
18
+ tests/test_mcp.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ sourceatlas-mcp = sourceatlas_mcp.__main__:main
@@ -0,0 +1 @@
1
+ mcp<2,>=1.29
@@ -0,0 +1 @@
1
+ sourceatlas_mcp
@@ -0,0 +1,41 @@
1
+ import unittest
2
+ from sourceatlas_mcp.core import *
3
+
4
+ A = {"title":"Reference A","url":"https://example.org/report?utm_campaign=a&id=1#section","publisher":"Research Lab","published":"2024-01-01","kind":"primary"}
5
+ B = {"title":"Reference B","url":"https://EXAMPLE.org:443/report?id=1","doi":"10.1234/example","published":"2024-01-02"}
6
+ C = {"title":"Reference C","doi":"https://doi.org/10.1234/EXAMPLE"}
7
+ class CoreTests(unittest.TestCase):
8
+ def test_normalization(self):
9
+ self.assertEqual(normalize_record(A)["url"],"https://example.org/report?id=1")
10
+ self.assertEqual(normalize_record(C)["doi"],"10.1234/example")
11
+ def test_merge_transitive_and_conflicts(self):
12
+ out=organize([A,B,C])
13
+ self.assertEqual(out["unique_count"],1)
14
+ self.assertEqual(out["groups"][0]["member_indexes"],[0,1,2])
15
+ self.assertEqual(out["groups"][0]["conflicts"]["published"],["2024-01-01","2024-01-02"])
16
+ def test_bad_urls(self):
17
+ for url in ("file:///tmp/ref","http://localhost/a","http://127.0.0.1/a","https://user:pass@example.org/","https://example.org:123/path"):
18
+ with self.subTest(url=url), self.assertRaises(ValueError):
19
+ normalize_url(url)
20
+ def test_recency(self):
21
+ for rec,expected in [(A,"stale"),(C,"missing"),({**A,"published":"2026-01-01"},"future")]:
22
+ self.assertEqual(recency([rec],"2025-01-01",30)["items"][0]["recency"],expected)
23
+ self.assertEqual(recency([A,B],"2025-01-01")["items"][0]["recency"],"conflicting")
24
+ def test_markdown(self):
25
+ out=evidence_table([{**A,"title":"A | <b> [unsafe](x)"}])
26
+ self.assertIn("&#124;",out)
27
+ self.assertNotIn("<b>",out)
28
+ self.assertEqual(citation(C),"Reference C. Publisher not supplied. Date not supplied. https://doi.org/10.1234/example")
29
+ def test_validation(self):
30
+ for record in [{"title":"X"},{"title":"X","url":"https://example.org","published":"2025-02-29"},{**A,"extra":True},{**A,"kind":"made-up"}]:
31
+ with self.assertRaises(ValueError):
32
+ normalize_record(record)
33
+ with self.assertRaises(ValueError):
34
+ organize([A]*101)
35
+ with self.assertRaises(ValueError):
36
+ normalize_record({"title":"X","url":"https://doi.org/10.1234/x","doi":"10.1234/y"})
37
+
38
+ def test_query_encoding_not_lossy(self):
39
+ self.assertEqual(normalize_url("https://example.org/x?q=%C3%A9"), "https://example.org/x?q=%C3%A9")
40
+ with self.assertRaises(ValueError):
41
+ normalize_url("https://example.org/x?q=%FF")
@@ -0,0 +1,25 @@
1
+ import sys
2
+ import unittest
3
+ from mcp import ClientSession, StdioServerParameters
4
+ from mcp.client.stdio import stdio_client
5
+
6
+ class MCPIntegration(unittest.IsolatedAsyncioTestCase):
7
+ async def test_stdio_session(self):
8
+ record={"title":"Public report","url":"https://example.org/report","published":"2024-01-01"}
9
+ async with stdio_client(StdioServerParameters(command=sys.executable,args=["-m","sourceatlas_mcp"])) as (reader,writer):
10
+ async with ClientSession(reader,writer) as session:
11
+ await session.initialize()
12
+ tools=await session.list_tools()
13
+ self.assertEqual({t.name for t in tools.tools},{"normalize_source","group_sources","format_citation","check_recency","build_evidence_table"})
14
+ for name,args,needle in [
15
+ ("normalize_source",{"record":record},"example.org/report"),
16
+ ("group_sources",{"records":[record,record]},"unique_count"),
17
+ ("format_citation",{"record":record},"Public report"),
18
+ ("check_recency",{"records":[record],"as_of":"2025-01-01"},"stale"),
19
+ ("build_evidence_table",{"records":[record]},"Evidence inventory"),
20
+ ]:
21
+ result=await session.call_tool(name,args)
22
+ self.assertFalse(result.isError,result)
23
+ self.assertIn(needle,str(result.content))
24
+ bad=await session.call_tool("normalize_source",{"record":{"title":"Bad","url":"http://localhost"}})
25
+ self.assertTrue(bad.isError)