psrmcp 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.
Files changed (87) hide show
  1. psrmcp-0.1.0/.gitignore +25 -0
  2. psrmcp-0.1.0/.gitlab-ci.yml +58 -0
  3. psrmcp-0.1.0/.python-version +1 -0
  4. psrmcp-0.1.0/LICENSE +21 -0
  5. psrmcp-0.1.0/PKG-INFO +83 -0
  6. psrmcp-0.1.0/README.md +64 -0
  7. psrmcp-0.1.0/docs/DESIGN.md +571 -0
  8. psrmcp-0.1.0/docs/FEATURES.md +114 -0
  9. psrmcp-0.1.0/docs/INSTALL.md +184 -0
  10. psrmcp-0.1.0/docs/TOOLS.md +2247 -0
  11. psrmcp-0.1.0/docs/TUTORIAL.md +302 -0
  12. psrmcp-0.1.0/examples/client_stdio.py +81 -0
  13. psrmcp-0.1.0/pyproject.toml +42 -0
  14. psrmcp-0.1.0/scripts/dev_env.sh +50 -0
  15. psrmcp-0.1.0/scripts/install_pulsar_stack.sh +1995 -0
  16. psrmcp-0.1.0/scripts/live_check.py +101 -0
  17. psrmcp-0.1.0/scripts/make_synth_fil.py +89 -0
  18. psrmcp-0.1.0/scripts/versions.env +80 -0
  19. psrmcp-0.1.0/src/psrmcp/__init__.py +5 -0
  20. psrmcp-0.1.0/src/psrmcp/_context.py +44 -0
  21. psrmcp-0.1.0/src/psrmcp/adapters/base.py +185 -0
  22. psrmcp-0.1.0/src/psrmcp/adapters/dspsr.py +50 -0
  23. psrmcp-0.1.0/src/psrmcp/adapters/pint.py +58 -0
  24. psrmcp-0.1.0/src/psrmcp/adapters/psrcat.py +197 -0
  25. psrmcp-0.1.0/src/psrmcp/adapters/psrchive.py +168 -0
  26. psrmcp-0.1.0/src/psrmcp/adapters/tempo2.py +33 -0
  27. psrmcp-0.1.0/src/psrmcp/config.py +196 -0
  28. psrmcp-0.1.0/src/psrmcp/errors.py +106 -0
  29. psrmcp-0.1.0/src/psrmcp/execution/jobs.py +221 -0
  30. psrmcp-0.1.0/src/psrmcp/execution/runner.py +203 -0
  31. psrmcp-0.1.0/src/psrmcp/execution/tasks.py +19 -0
  32. psrmcp-0.1.0/src/psrmcp/execution/workspace.py +227 -0
  33. psrmcp-0.1.0/src/psrmcp/ids.py +22 -0
  34. psrmcp-0.1.0/src/psrmcp/models/common.py +159 -0
  35. psrmcp-0.1.0/src/psrmcp/models/inputs.py +282 -0
  36. psrmcp-0.1.0/src/psrmcp/models/results.py +473 -0
  37. psrmcp-0.1.0/src/psrmcp/paths.py +120 -0
  38. psrmcp-0.1.0/src/psrmcp/plotting/__init__.py +1 -0
  39. psrmcp-0.1.0/src/psrmcp/plotting/profile_plots.py +51 -0
  40. psrmcp-0.1.0/src/psrmcp/plotting/style.py +28 -0
  41. psrmcp-0.1.0/src/psrmcp/prompts.py +141 -0
  42. psrmcp-0.1.0/src/psrmcp/resources.py +150 -0
  43. psrmcp-0.1.0/src/psrmcp/server.py +170 -0
  44. psrmcp-0.1.0/src/psrmcp/tools/_common.py +92 -0
  45. psrmcp-0.1.0/src/psrmcp/tools/archive.py +300 -0
  46. psrmcp-0.1.0/src/psrmcp/tools/artifacts.py +62 -0
  47. psrmcp-0.1.0/src/psrmcp/tools/catalog.py +449 -0
  48. psrmcp-0.1.0/src/psrmcp/tools/data.py +128 -0
  49. psrmcp-0.1.0/src/psrmcp/tools/dedispersion.py +209 -0
  50. psrmcp-0.1.0/src/psrmcp/tools/profile.py +219 -0
  51. psrmcp-0.1.0/src/psrmcp/tools/registry.py +173 -0
  52. psrmcp-0.1.0/src/psrmcp/tools/rfi.py +211 -0
  53. psrmcp-0.1.0/src/psrmcp/tools/system.py +87 -0
  54. psrmcp-0.1.0/src/psrmcp/tools/timing.py +445 -0
  55. psrmcp-0.1.0/src/psrmcp/workers/pint_worker.py +308 -0
  56. psrmcp-0.1.0/tests/conftest.py +92 -0
  57. psrmcp-0.1.0/tests/contract/conftest.py +16 -0
  58. psrmcp-0.1.0/tests/contract/test_contract_gated.py +184 -0
  59. psrmcp-0.1.0/tests/fixtures/toolsmd/archive_convert.input.json +31 -0
  60. psrmcp-0.1.0/tests/fixtures/toolsmd/archive_inspect.input.json +37 -0
  61. psrmcp-0.1.0/tests/fixtures/toolsmd/archive_merge.input.json +46 -0
  62. psrmcp-0.1.0/tests/fixtures/toolsmd/artifact_list.input.json +37 -0
  63. psrmcp-0.1.0/tests/fixtures/toolsmd/catalog_get.input.json +17 -0
  64. psrmcp-0.1.0/tests/fixtures/toolsmd/catalog_search.input.json +77 -0
  65. psrmcp-0.1.0/tests/fixtures/toolsmd/data_find.input.json +45 -0
  66. psrmcp-0.1.0/tests/fixtures/toolsmd/dedisperse.input.json +74 -0
  67. psrmcp-0.1.0/tests/fixtures/toolsmd/ephemeris_export.input.json +74 -0
  68. psrmcp-0.1.0/tests/fixtures/toolsmd/job_cancel.input.json +20 -0
  69. psrmcp-0.1.0/tests/fixtures/toolsmd/job_get.input.json +15 -0
  70. psrmcp-0.1.0/tests/fixtures/toolsmd/profile_measure.input.json +49 -0
  71. psrmcp-0.1.0/tests/fixtures/toolsmd/profile_standardize.input.json +38 -0
  72. psrmcp-0.1.0/tests/fixtures/toolsmd/pulsar_environment.input.json +13 -0
  73. psrmcp-0.1.0/tests/fixtures/toolsmd/rfi_scan.input.json +35 -0
  74. psrmcp-0.1.0/tests/fixtures/toolsmd/rfi_zap.input.json +75 -0
  75. psrmcp-0.1.0/tests/fixtures/toolsmd/timing_diagnose.input.json +58 -0
  76. psrmcp-0.1.0/tests/fixtures/toolsmd/timing_fit.input.json +68 -0
  77. psrmcp-0.1.0/tests/fixtures/toolsmd/toa_extract.input.json +66 -0
  78. psrmcp-0.1.0/tests/unit/test_adapters.py +151 -0
  79. psrmcp-0.1.0/tests/unit/test_config.py +32 -0
  80. psrmcp-0.1.0/tests/unit/test_jobs.py +91 -0
  81. psrmcp-0.1.0/tests/unit/test_paths.py +116 -0
  82. psrmcp-0.1.0/tests/unit/test_runner.py +73 -0
  83. psrmcp-0.1.0/tests/unit/test_schema_contract.py +99 -0
  84. psrmcp-0.1.0/tests/unit/test_server_cli.py +46 -0
  85. psrmcp-0.1.0/tests/unit/test_tools_offline.py +157 -0
  86. psrmcp-0.1.0/tests/unit/test_workspace.py +76 -0
  87. psrmcp-0.1.0/uv.lock +2021 -0
@@ -0,0 +1,25 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ .venv/
6
+ dist/
7
+ build/
8
+
9
+ # Tooling
10
+ .pytest_cache/
11
+ .ruff_cache/
12
+ .mypy_cache/
13
+ .coverage
14
+ htmlcov/
15
+
16
+ # Editors
17
+ .idea/
18
+ .vscode/
19
+ *.swp
20
+
21
+ # Local runtime state
22
+ *.log
23
+ .claude/settings.local.json
24
+ config.toml
25
+ ws/
@@ -0,0 +1,58 @@
1
+ # CI:单元测试 + PyPI 自动发布(PyPI Trusted Publishing / OIDC,CI 中无长期 token)。
2
+ #
3
+ # 首次发布前的一次性设置(pypi.org):
4
+ # 登录 → Account settings → Publishing → Add a new pending publisher
5
+ # PyPI project name: psrmcp
6
+ # Pending publisher: GitLab CI/CD
7
+ # Owner (namespace): zhangyazhou416
8
+ # Repository name: psrmcp
9
+ # Workflow filename: .gitlab-ci.yml
10
+ # (项目首次发布成功后,改在项目页 Project settings → Publishing 管理)
11
+ #
12
+ # 发布方式:打 tag 即自动构建上传
13
+ # git tag v0.1.0 && git push origin v0.1.0
14
+ # (注意保持 tag 与 pyproject.toml 的 version 一致;PyPI 禁止同版本重传)
15
+
16
+ stages:
17
+ - test
18
+ - publish
19
+
20
+ unit-tests:
21
+ stage: test
22
+ image: ghcr.io/astral-sh/uv:python3.12-bookworm
23
+ cache:
24
+ key:
25
+ files:
26
+ - uv.lock
27
+ paths:
28
+ - .venv/
29
+ script:
30
+ - uv sync
31
+ - uv run pytest tests/unit -q
32
+
33
+ publish-pypi:
34
+ stage: publish
35
+ image: ghcr.io/astral-sh/uv:python3.12-bookworm
36
+ id_tokens:
37
+ PYPI_ID_TOKEN: # GitLab OIDC ID token;aud 必须为 pypi
38
+ aud: pypi
39
+ script:
40
+ - uv build
41
+ # 用 OIDC ID token 向 PyPI 换一次性上传 token(UV_PUBLISH_TOKEN 为 uv publish 认可)
42
+ - |
43
+ cat > /tmp/mint_token.py <<'PY'
44
+ import json, os, urllib.request
45
+
46
+ req = urllib.request.Request(
47
+ "https://pypi.org/_/oidc/mint-token",
48
+ data=json.dumps({"token": os.environ["PYPI_ID_TOKEN"]}).encode(),
49
+ headers={"Content-Type": "application/json"},
50
+ )
51
+ with urllib.request.urlopen(req) as resp:
52
+ print(json.load(resp)["token"])
53
+ PY
54
+ export UV_PUBLISH_TOKEN="$(python3 /tmp/mint_token.py)"
55
+ uv publish
56
+ rules:
57
+ - if: $CI_COMMIT_TAG # 仅打 tag 时发布;tag 也可在 GitLab 页面手动跑此 job
58
+ when: on_success
@@ -0,0 +1 @@
1
+ 3.12
psrmcp-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 zhangyazhou
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.
psrmcp-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,83 @@
1
+ Metadata-Version: 2.5
2
+ Name: psrmcp
3
+ Version: 0.1.0
4
+ Summary: MCP server wrapping pulsar astronomy software (dspsr, psrchive, tempo2, psrcat, PINT)
5
+ Project-URL: Repository, https://gitlab.com/zhangyazhou416/psrmcp
6
+ Project-URL: Issues, https://gitlab.com/zhangyazhou416/psrmcp/-/issues
7
+ Author: psrmcp contributors
8
+ License: MIT
9
+ License-File: LICENSE
10
+ Requires-Python: >=3.12
11
+ Requires-Dist: astropy<9,>=8.0
12
+ Requires-Dist: matplotlib<4,>=3.11
13
+ Requires-Dist: mcp<3,>=2.3
14
+ Requires-Dist: numpy<3,>=2.1
15
+ Requires-Dist: pint-pulsar<2,>=1.1
16
+ Requires-Dist: psrqpy<2,>=1.3
17
+ Requires-Dist: pydantic<3,>=2.14
18
+ Description-Content-Type: text/markdown
19
+
20
+ # psrmcp
21
+
22
+ 把脉冲星天文软件链(dspsr / psrchive / tempo2 / psrcat / PINT)封装成 MCP(Model Context Protocol)Server:面向任务的工具、参数受控、结果结构化、全程可追溯。
23
+
24
+ 仓库:<https://gitlab.com/zhangyazhou416/psrmcp>
25
+
26
+ - 功能总览:[docs/FEATURES.md](docs/FEATURES.md)(能做什么、19 个工具一览)
27
+ - 使用教程:[docs/TUTORIAL.md](docs/TUTORIAL.md)(安装配置、接入客户端、完整处理链实战)
28
+ - 设计方案:[docs/DESIGN.md](docs/DESIGN.md)
29
+ - 工具契约:[docs/TOOLS.md](docs/TOOLS.md)(19 个工具的输入/输出 Schema)
30
+ - 一键安装脉冲星软件栈:[scripts/install_pulsar_stack.sh](scripts/install_pulsar_stack.sh)(全源码编译进 `~/.pulsar`,详见 [docs/INSTALL.md](docs/INSTALL.md))
31
+
32
+ ## 快速开始
33
+
34
+ ```bash
35
+ # 1. 安装脉冲星软件栈(可选,缺省时服务器会优雅降级并在 pulsar_environment 中报告)
36
+ bash scripts/install_pulsar_stack.sh # 加 --with-presto 连 PRESTO 一起装
37
+
38
+ # 2. 准备 MCP 服务器环境
39
+ uv sync
40
+
41
+ # 3. 生成默认配置并启动(stdio)
42
+ uv run psrmcp --init-config ~/.psrmcp.toml
43
+ PSRMCP_CONFIG=~/.psrmcp.toml uv run psrmcp
44
+ ```
45
+
46
+ ### 接入 MCP 客户端(如 Claude Code / Desktop)
47
+
48
+ ```json
49
+ {
50
+ "mcpServers": {
51
+ "psrmcp": {
52
+ "command": "uv",
53
+ "args": ["--directory", "/path/to/psrmcp", "run", "psrmcp"],
54
+ "env": {"PSRMCP_CONFIG": "~/.psrmcp.toml"}
55
+ }
56
+ }
57
+ }
58
+ ```
59
+
60
+ ## 开发
61
+
62
+ ```bash
63
+ uv run pytest -q # 单元测试(不需要安装任何后端)
64
+ PSRMCP_CONTRACT=1 uv run pytest tests/contract # 契约测试(需要已安装软件栈)
65
+ ```
66
+
67
+ ## 发布到 PyPI
68
+
69
+ CI 自动发布([.gitlab-ci.yml](.gitlab-ci.yml),PyPI Trusted Publishing / OIDC,CI 中无长期凭据):
70
+
71
+ ```bash
72
+ git tag v0.1.0 && git push origin v0.1.0 # 打 tag 即构建并上传(tag 与 version 保持一致)
73
+ ```
74
+
75
+ 首次发布前需在 pypi.org 登记 pending publisher(Owner `zhangyazhou416`、Repository `psrmcp`、Workflow `.gitlab-ci.yml`),见 CI 文件顶部注释。手动发布:`uv build && uv publish`。
76
+
77
+ ## 状态
78
+
79
+ v0.1.0 — MVP(Phase 0–2):环境自检、数据发现、星表查询、archive 检查/转换/合并、消色散、RFI、标准轮廓、TOA、PINT 计时拟合与诊断。
80
+
81
+ ## 许可
82
+
83
+ [MIT](LICENSE)
psrmcp-0.1.0/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # psrmcp
2
+
3
+ 把脉冲星天文软件链(dspsr / psrchive / tempo2 / psrcat / PINT)封装成 MCP(Model Context Protocol)Server:面向任务的工具、参数受控、结果结构化、全程可追溯。
4
+
5
+ 仓库:<https://gitlab.com/zhangyazhou416/psrmcp>
6
+
7
+ - 功能总览:[docs/FEATURES.md](docs/FEATURES.md)(能做什么、19 个工具一览)
8
+ - 使用教程:[docs/TUTORIAL.md](docs/TUTORIAL.md)(安装配置、接入客户端、完整处理链实战)
9
+ - 设计方案:[docs/DESIGN.md](docs/DESIGN.md)
10
+ - 工具契约:[docs/TOOLS.md](docs/TOOLS.md)(19 个工具的输入/输出 Schema)
11
+ - 一键安装脉冲星软件栈:[scripts/install_pulsar_stack.sh](scripts/install_pulsar_stack.sh)(全源码编译进 `~/.pulsar`,详见 [docs/INSTALL.md](docs/INSTALL.md))
12
+
13
+ ## 快速开始
14
+
15
+ ```bash
16
+ # 1. 安装脉冲星软件栈(可选,缺省时服务器会优雅降级并在 pulsar_environment 中报告)
17
+ bash scripts/install_pulsar_stack.sh # 加 --with-presto 连 PRESTO 一起装
18
+
19
+ # 2. 准备 MCP 服务器环境
20
+ uv sync
21
+
22
+ # 3. 生成默认配置并启动(stdio)
23
+ uv run psrmcp --init-config ~/.psrmcp.toml
24
+ PSRMCP_CONFIG=~/.psrmcp.toml uv run psrmcp
25
+ ```
26
+
27
+ ### 接入 MCP 客户端(如 Claude Code / Desktop)
28
+
29
+ ```json
30
+ {
31
+ "mcpServers": {
32
+ "psrmcp": {
33
+ "command": "uv",
34
+ "args": ["--directory", "/path/to/psrmcp", "run", "psrmcp"],
35
+ "env": {"PSRMCP_CONFIG": "~/.psrmcp.toml"}
36
+ }
37
+ }
38
+ }
39
+ ```
40
+
41
+ ## 开发
42
+
43
+ ```bash
44
+ uv run pytest -q # 单元测试(不需要安装任何后端)
45
+ PSRMCP_CONTRACT=1 uv run pytest tests/contract # 契约测试(需要已安装软件栈)
46
+ ```
47
+
48
+ ## 发布到 PyPI
49
+
50
+ CI 自动发布([.gitlab-ci.yml](.gitlab-ci.yml),PyPI Trusted Publishing / OIDC,CI 中无长期凭据):
51
+
52
+ ```bash
53
+ git tag v0.1.0 && git push origin v0.1.0 # 打 tag 即构建并上传(tag 与 version 保持一致)
54
+ ```
55
+
56
+ 首次发布前需在 pypi.org 登记 pending publisher(Owner `zhangyazhou416`、Repository `psrmcp`、Workflow `.gitlab-ci.yml`),见 CI 文件顶部注释。手动发布:`uv build && uv publish`。
57
+
58
+ ## 状态
59
+
60
+ v0.1.0 — MVP(Phase 0–2):环境自检、数据发现、星表查询、archive 检查/转换/合并、消色散、RFI、标准轮廓、TOA、PINT 计时拟合与诊断。
61
+
62
+ ## 许可
63
+
64
+ [MIT](LICENSE)