telos-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.
- telos_mcp-0.1.0/.gitignore +7 -0
- telos_mcp-0.1.0/LICENSE +200 -0
- telos_mcp-0.1.0/PKG-INFO +230 -0
- telos_mcp-0.1.0/README.md +201 -0
- telos_mcp-0.1.0/pyproject.toml +65 -0
- telos_mcp-0.1.0/server.json +31 -0
- telos_mcp-0.1.0/telos_mcp/__init__.py +15 -0
- telos_mcp-0.1.0/telos_mcp/engine.py +64 -0
- telos_mcp-0.1.0/telos_mcp/engine_real.py +54 -0
- telos_mcp-0.1.0/telos_mcp/engine_stub.py +256 -0
- telos_mcp-0.1.0/telos_mcp/server.py +226 -0
telos_mcp-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may accept support,
|
|
167
|
+
warranty, indemnity, or other liability obligations and/or rights
|
|
168
|
+
consistent with this License. However, in accepting such obligations,
|
|
169
|
+
You may act only on Your own behalf and on Your sole responsibility,
|
|
170
|
+
not on behalf of any other Contributor, and only if You agree to
|
|
171
|
+
indemnify, defend, and hold each Contributor harmless for any
|
|
172
|
+
liability incurred by, or claims asserted against, such Contributor
|
|
173
|
+
by reason of your accepting any such warranty or additional liability.
|
|
174
|
+
|
|
175
|
+
END OF TERMS AND CONDITIONS
|
|
176
|
+
|
|
177
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
178
|
+
|
|
179
|
+
To apply the Apache License to your work, attach the following
|
|
180
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
181
|
+
replaced with your own identifying information. (Don't include
|
|
182
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
183
|
+
comment syntax for the file format. We also recommend that a
|
|
184
|
+
file or class name and description of purpose be included on the
|
|
185
|
+
same "printed page" as the copyright notice for easier
|
|
186
|
+
identification within third-party archives.
|
|
187
|
+
|
|
188
|
+
Copyright 2026 TELOS AI Labs
|
|
189
|
+
|
|
190
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
191
|
+
you may not use this file except in compliance with the License.
|
|
192
|
+
You may obtain a copy of the License at
|
|
193
|
+
|
|
194
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
195
|
+
|
|
196
|
+
Unless required by applicable law or agreed to in writing, software
|
|
197
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
198
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
199
|
+
See the License for the specific language governing permissions and
|
|
200
|
+
limitations under the License.
|
telos_mcp-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: telos-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Model Context Protocol server for TELOS AI Labs governance (scoring, unsigned integrity-hash receipts, audit chain, CCRS replay).
|
|
5
|
+
Project-URL: Homepage, https://telos-labs.ai
|
|
6
|
+
Project-URL: Repository, https://github.com/TELOS-Labs-AI/telos-mcp
|
|
7
|
+
Project-URL: Issues, https://github.com/TELOS-Labs-AI/telos-mcp/issues
|
|
8
|
+
Project-URL: Documentation, https://github.com/TELOS-Labs-AI/telos-mcp#readme
|
|
9
|
+
Author-email: TELOS AI Labs <team@telos-labs.ai>
|
|
10
|
+
License: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: agent-governance,ai-governance,audit-chain,mcp,model-context-protocol,telos
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Requires-Dist: mcp>=1.12.0
|
|
24
|
+
Requires-Dist: telos-receipt>=0.1.0
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
27
|
+
Requires-Dist: ruff>=0.5; extra == 'dev'
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# telos-mcp
|
|
31
|
+
|
|
32
|
+
**Model Context Protocol server for TELOS AI Labs governance.**
|
|
33
|
+
|
|
34
|
+
Exposes TELOS governance primitives -- action scoring, unsigned
|
|
35
|
+
integrity-hash receipt verification, Purpose Anchor inspection, audit-chain
|
|
36
|
+
queries, and CCRS counterfactual replay -- as MCP tools, resources, and prompts. Any
|
|
37
|
+
MCP-compatible client (Claude Desktop, Claude Code, Cursor, Cline, etc.)
|
|
38
|
+
can call them as native tools.
|
|
39
|
+
|
|
40
|
+
> **v0.1 status.** This release ships the protocol surface with **stubbed**
|
|
41
|
+
> engine calls so clients can exercise every tool, resource, and prompt
|
|
42
|
+
> end-to-end without an installed engine. Scores are synthetic and receipts are
|
|
43
|
+
> **unsigned integrity-hash** receipts (`signature: null`,
|
|
44
|
+
> `signing_status: "unsigned_integrity_hash"`): a key-free SHA-256 over the
|
|
45
|
+
> receipt payload, not a digital signature. v0.2 wires the live `telos-gov`
|
|
46
|
+
> engine behind the same receipt shape, and a real signature fills the existing
|
|
47
|
+
> `signature` field then, with no schema break.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## What this server exposes
|
|
52
|
+
|
|
53
|
+
### Tools (LLM-callable)
|
|
54
|
+
|
|
55
|
+
| Tool | Purpose |
|
|
56
|
+
|------|---------|
|
|
57
|
+
| `telos_score(action_name, action_params, agent_id)` | Score a proposed action against the active Purpose Anchor. Returns verdict (`EXECUTE` / `CLARIFY` / `ESCALATE`) plus per-dimension scores across `purpose`, `scope`, `boundary`, `tool`, `chain`, `codebase_fidelity`, plus an unsigned integrity-hash receipt envelope. |
|
|
58
|
+
| `telos_verify(receipt_json)` | Verify an unsigned integrity-hash receipt offline (key-free; not a signature check). Returns `{match, recomputed_integrity_hash, signing_status, reason, ...}`. |
|
|
59
|
+
| `telos_get_pa(agent_id)` | Return the active Purpose Anchor: purpose, hard boundaries, declared scope, allowed tools, centroid dimensions. |
|
|
60
|
+
| `telos_audit(start_iso, end_iso)` | Return audit-chain entries within a time window (capped at 100). |
|
|
61
|
+
| `telos_replay(receipt_id, alt_config_path)` | Queue a CCRS counterfactual replay against an alternate config; returns a `job_id`. |
|
|
62
|
+
|
|
63
|
+
### Resources (LLM-readable)
|
|
64
|
+
|
|
65
|
+
| URI template | Returns |
|
|
66
|
+
|--------------|---------|
|
|
67
|
+
| `telos://wiki/{path}` | A TELOS governance wiki page by relative path. |
|
|
68
|
+
| `telos://centroids/{dimension}` | Compiled centroid metadata for one of `purpose`, `scope`, `boundary`, `tool`, `chain`, `codebase_fidelity`. |
|
|
69
|
+
| `telos://audit/{date}` | The audit-chain segment for a given `YYYY-MM-DD` (UTC). |
|
|
70
|
+
|
|
71
|
+
### Prompts (user-invokable templates)
|
|
72
|
+
|
|
73
|
+
| Prompt | Purpose |
|
|
74
|
+
|--------|---------|
|
|
75
|
+
| `governance_review(action)` | Have the model review a proposed action for governance compliance. |
|
|
76
|
+
| `audit_walkthrough(start_date, end_date)` | Walk through the audit chain in a date window. |
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Install
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
pip install telos-mcp
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
The live engine (`telos-gov`) lands in v0.2, after the clean-facade
|
|
87
|
+
republish. v0.1 ships no installable engine extra; the stub is the only
|
|
88
|
+
supported engine. (`telos-mcp[engine]` returns in v0.2 pinned to the
|
|
89
|
+
republished clean facade.)
|
|
90
|
+
|
|
91
|
+
The package installs a `telos-mcp` console script that starts the server
|
|
92
|
+
over stdio. You can also invoke it via `python -m telos_mcp.server`.
|
|
93
|
+
|
|
94
|
+
Requires Python 3.10+.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Client configuration
|
|
99
|
+
|
|
100
|
+
Each client below assumes `telos-mcp` is installed in a Python environment
|
|
101
|
+
on `PATH`. If you prefer not to install globally, use `uvx telos-mcp` or
|
|
102
|
+
substitute the absolute path to the `telos-mcp` script in the snippets.
|
|
103
|
+
|
|
104
|
+
### Claude Desktop
|
|
105
|
+
|
|
106
|
+
Edit `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
107
|
+
(macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows). Add
|
|
108
|
+
the `telos-governance` entry under `mcpServers`:
|
|
109
|
+
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"mcpServers": {
|
|
113
|
+
"telos-governance": {
|
|
114
|
+
"command": "telos-mcp",
|
|
115
|
+
"args": [],
|
|
116
|
+
"env": {
|
|
117
|
+
"TELOS_AGENT_ID": "claude-desktop-default"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Restart Claude Desktop. The five `telos_*` tools should appear in the
|
|
125
|
+
MCP tool tray.
|
|
126
|
+
|
|
127
|
+
### Claude Code
|
|
128
|
+
|
|
129
|
+
Use the `claude mcp add` CLI:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
claude mcp add telos-governance -- telos-mcp
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Or edit `~/.config/claude-code/mcp_servers.json` directly:
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"telos-governance": {
|
|
140
|
+
"command": "telos-mcp",
|
|
141
|
+
"args": []
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Cursor
|
|
147
|
+
|
|
148
|
+
Edit `~/.cursor/mcp.json` (global) or `.cursor/mcp.json` (per-project):
|
|
149
|
+
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"mcpServers": {
|
|
153
|
+
"telos-governance": {
|
|
154
|
+
"command": "telos-mcp",
|
|
155
|
+
"args": [],
|
|
156
|
+
"env": {
|
|
157
|
+
"TELOS_AGENT_ID": "cursor-default"
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Cline (VS Code extension)
|
|
165
|
+
|
|
166
|
+
Open Cline -> MCP Servers -> Edit Configuration. Add:
|
|
167
|
+
|
|
168
|
+
```json
|
|
169
|
+
{
|
|
170
|
+
"mcpServers": {
|
|
171
|
+
"telos-governance": {
|
|
172
|
+
"command": "telos-mcp",
|
|
173
|
+
"args": [],
|
|
174
|
+
"transportType": "stdio"
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Verifying the install
|
|
181
|
+
|
|
182
|
+
From any client, ask:
|
|
183
|
+
|
|
184
|
+
> Use the `telos_get_pa` tool with `agent_id="test"` and show the
|
|
185
|
+
> Purpose Anchor.
|
|
186
|
+
|
|
187
|
+
You should see a stub PA back containing `"stub": true` and the six
|
|
188
|
+
canonical centroid dimensions.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Development
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
git clone https://github.com/TELOS-Labs-AI/telos-mcp
|
|
196
|
+
cd telos-mcp
|
|
197
|
+
python -m venv .venv && source .venv/bin/activate
|
|
198
|
+
pip install -e ".[dev]"
|
|
199
|
+
|
|
200
|
+
# Run the server over stdio (what MCP clients spawn):
|
|
201
|
+
python -m telos_mcp.server
|
|
202
|
+
|
|
203
|
+
# Or use the MCP Inspector for interactive exploration:
|
|
204
|
+
mcp dev telos_mcp/server.py
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## Roadmap
|
|
210
|
+
|
|
211
|
+
- **v0.1 (this release)** -- protocol surface complete, engine stubbed,
|
|
212
|
+
registry-submission-ready manifest.
|
|
213
|
+
- **v0.2** -- swap stubs for live `telos-gov` calls (after the clean-facade
|
|
214
|
+
republish). Receipts gain a real signature after the signing ceremony, filling
|
|
215
|
+
the existing `signature` field with no schema break. `telos-gov` becomes a
|
|
216
|
+
hard dependency.
|
|
217
|
+
- **v0.3** -- streaming audit subscriptions, per-tenant PA selection via
|
|
218
|
+
`TELOS_TENANT` env, optional HTTP transport.
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## License
|
|
223
|
+
|
|
224
|
+
Apache-2.0. See [`LICENSE`](LICENSE).
|
|
225
|
+
|
|
226
|
+
## Links
|
|
227
|
+
|
|
228
|
+
- TELOS AI Labs: https://telos-labs.ai
|
|
229
|
+
- Source: https://github.com/TELOS-Labs-AI/telos-mcp
|
|
230
|
+
- Issues: https://github.com/TELOS-Labs-AI/telos-mcp/issues
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# telos-mcp
|
|
2
|
+
|
|
3
|
+
**Model Context Protocol server for TELOS AI Labs governance.**
|
|
4
|
+
|
|
5
|
+
Exposes TELOS governance primitives -- action scoring, unsigned
|
|
6
|
+
integrity-hash receipt verification, Purpose Anchor inspection, audit-chain
|
|
7
|
+
queries, and CCRS counterfactual replay -- as MCP tools, resources, and prompts. Any
|
|
8
|
+
MCP-compatible client (Claude Desktop, Claude Code, Cursor, Cline, etc.)
|
|
9
|
+
can call them as native tools.
|
|
10
|
+
|
|
11
|
+
> **v0.1 status.** This release ships the protocol surface with **stubbed**
|
|
12
|
+
> engine calls so clients can exercise every tool, resource, and prompt
|
|
13
|
+
> end-to-end without an installed engine. Scores are synthetic and receipts are
|
|
14
|
+
> **unsigned integrity-hash** receipts (`signature: null`,
|
|
15
|
+
> `signing_status: "unsigned_integrity_hash"`): a key-free SHA-256 over the
|
|
16
|
+
> receipt payload, not a digital signature. v0.2 wires the live `telos-gov`
|
|
17
|
+
> engine behind the same receipt shape, and a real signature fills the existing
|
|
18
|
+
> `signature` field then, with no schema break.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## What this server exposes
|
|
23
|
+
|
|
24
|
+
### Tools (LLM-callable)
|
|
25
|
+
|
|
26
|
+
| Tool | Purpose |
|
|
27
|
+
|------|---------|
|
|
28
|
+
| `telos_score(action_name, action_params, agent_id)` | Score a proposed action against the active Purpose Anchor. Returns verdict (`EXECUTE` / `CLARIFY` / `ESCALATE`) plus per-dimension scores across `purpose`, `scope`, `boundary`, `tool`, `chain`, `codebase_fidelity`, plus an unsigned integrity-hash receipt envelope. |
|
|
29
|
+
| `telos_verify(receipt_json)` | Verify an unsigned integrity-hash receipt offline (key-free; not a signature check). Returns `{match, recomputed_integrity_hash, signing_status, reason, ...}`. |
|
|
30
|
+
| `telos_get_pa(agent_id)` | Return the active Purpose Anchor: purpose, hard boundaries, declared scope, allowed tools, centroid dimensions. |
|
|
31
|
+
| `telos_audit(start_iso, end_iso)` | Return audit-chain entries within a time window (capped at 100). |
|
|
32
|
+
| `telos_replay(receipt_id, alt_config_path)` | Queue a CCRS counterfactual replay against an alternate config; returns a `job_id`. |
|
|
33
|
+
|
|
34
|
+
### Resources (LLM-readable)
|
|
35
|
+
|
|
36
|
+
| URI template | Returns |
|
|
37
|
+
|--------------|---------|
|
|
38
|
+
| `telos://wiki/{path}` | A TELOS governance wiki page by relative path. |
|
|
39
|
+
| `telos://centroids/{dimension}` | Compiled centroid metadata for one of `purpose`, `scope`, `boundary`, `tool`, `chain`, `codebase_fidelity`. |
|
|
40
|
+
| `telos://audit/{date}` | The audit-chain segment for a given `YYYY-MM-DD` (UTC). |
|
|
41
|
+
|
|
42
|
+
### Prompts (user-invokable templates)
|
|
43
|
+
|
|
44
|
+
| Prompt | Purpose |
|
|
45
|
+
|--------|---------|
|
|
46
|
+
| `governance_review(action)` | Have the model review a proposed action for governance compliance. |
|
|
47
|
+
| `audit_walkthrough(start_date, end_date)` | Walk through the audit chain in a date window. |
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Install
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pip install telos-mcp
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The live engine (`telos-gov`) lands in v0.2, after the clean-facade
|
|
58
|
+
republish. v0.1 ships no installable engine extra; the stub is the only
|
|
59
|
+
supported engine. (`telos-mcp[engine]` returns in v0.2 pinned to the
|
|
60
|
+
republished clean facade.)
|
|
61
|
+
|
|
62
|
+
The package installs a `telos-mcp` console script that starts the server
|
|
63
|
+
over stdio. You can also invoke it via `python -m telos_mcp.server`.
|
|
64
|
+
|
|
65
|
+
Requires Python 3.10+.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Client configuration
|
|
70
|
+
|
|
71
|
+
Each client below assumes `telos-mcp` is installed in a Python environment
|
|
72
|
+
on `PATH`. If you prefer not to install globally, use `uvx telos-mcp` or
|
|
73
|
+
substitute the absolute path to the `telos-mcp` script in the snippets.
|
|
74
|
+
|
|
75
|
+
### Claude Desktop
|
|
76
|
+
|
|
77
|
+
Edit `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
78
|
+
(macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows). Add
|
|
79
|
+
the `telos-governance` entry under `mcpServers`:
|
|
80
|
+
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"mcpServers": {
|
|
84
|
+
"telos-governance": {
|
|
85
|
+
"command": "telos-mcp",
|
|
86
|
+
"args": [],
|
|
87
|
+
"env": {
|
|
88
|
+
"TELOS_AGENT_ID": "claude-desktop-default"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Restart Claude Desktop. The five `telos_*` tools should appear in the
|
|
96
|
+
MCP tool tray.
|
|
97
|
+
|
|
98
|
+
### Claude Code
|
|
99
|
+
|
|
100
|
+
Use the `claude mcp add` CLI:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
claude mcp add telos-governance -- telos-mcp
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Or edit `~/.config/claude-code/mcp_servers.json` directly:
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"telos-governance": {
|
|
111
|
+
"command": "telos-mcp",
|
|
112
|
+
"args": []
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Cursor
|
|
118
|
+
|
|
119
|
+
Edit `~/.cursor/mcp.json` (global) or `.cursor/mcp.json` (per-project):
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
{
|
|
123
|
+
"mcpServers": {
|
|
124
|
+
"telos-governance": {
|
|
125
|
+
"command": "telos-mcp",
|
|
126
|
+
"args": [],
|
|
127
|
+
"env": {
|
|
128
|
+
"TELOS_AGENT_ID": "cursor-default"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Cline (VS Code extension)
|
|
136
|
+
|
|
137
|
+
Open Cline -> MCP Servers -> Edit Configuration. Add:
|
|
138
|
+
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"mcpServers": {
|
|
142
|
+
"telos-governance": {
|
|
143
|
+
"command": "telos-mcp",
|
|
144
|
+
"args": [],
|
|
145
|
+
"transportType": "stdio"
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Verifying the install
|
|
152
|
+
|
|
153
|
+
From any client, ask:
|
|
154
|
+
|
|
155
|
+
> Use the `telos_get_pa` tool with `agent_id="test"` and show the
|
|
156
|
+
> Purpose Anchor.
|
|
157
|
+
|
|
158
|
+
You should see a stub PA back containing `"stub": true` and the six
|
|
159
|
+
canonical centroid dimensions.
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Development
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
git clone https://github.com/TELOS-Labs-AI/telos-mcp
|
|
167
|
+
cd telos-mcp
|
|
168
|
+
python -m venv .venv && source .venv/bin/activate
|
|
169
|
+
pip install -e ".[dev]"
|
|
170
|
+
|
|
171
|
+
# Run the server over stdio (what MCP clients spawn):
|
|
172
|
+
python -m telos_mcp.server
|
|
173
|
+
|
|
174
|
+
# Or use the MCP Inspector for interactive exploration:
|
|
175
|
+
mcp dev telos_mcp/server.py
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Roadmap
|
|
181
|
+
|
|
182
|
+
- **v0.1 (this release)** -- protocol surface complete, engine stubbed,
|
|
183
|
+
registry-submission-ready manifest.
|
|
184
|
+
- **v0.2** -- swap stubs for live `telos-gov` calls (after the clean-facade
|
|
185
|
+
republish). Receipts gain a real signature after the signing ceremony, filling
|
|
186
|
+
the existing `signature` field with no schema break. `telos-gov` becomes a
|
|
187
|
+
hard dependency.
|
|
188
|
+
- **v0.3** -- streaming audit subscriptions, per-tenant PA selection via
|
|
189
|
+
`TELOS_TENANT` env, optional HTTP transport.
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## License
|
|
194
|
+
|
|
195
|
+
Apache-2.0. See [`LICENSE`](LICENSE).
|
|
196
|
+
|
|
197
|
+
## Links
|
|
198
|
+
|
|
199
|
+
- TELOS AI Labs: https://telos-labs.ai
|
|
200
|
+
- Source: https://github.com/TELOS-Labs-AI/telos-mcp
|
|
201
|
+
- Issues: https://github.com/TELOS-Labs-AI/telos-mcp/issues
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "telos-mcp"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Model Context Protocol server for TELOS AI Labs governance (scoring, unsigned integrity-hash receipts, audit chain, CCRS replay)."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "Apache-2.0" }
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "TELOS AI Labs", email = "team@telos-labs.ai" }
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"mcp",
|
|
17
|
+
"model-context-protocol",
|
|
18
|
+
"telos",
|
|
19
|
+
"ai-governance",
|
|
20
|
+
"agent-governance",
|
|
21
|
+
"audit-chain",
|
|
22
|
+
]
|
|
23
|
+
classifiers = [
|
|
24
|
+
"Development Status :: 3 - Alpha",
|
|
25
|
+
"Intended Audience :: Developers",
|
|
26
|
+
"License :: OSI Approved :: Apache Software License",
|
|
27
|
+
"Operating System :: OS Independent",
|
|
28
|
+
"Programming Language :: Python :: 3",
|
|
29
|
+
"Programming Language :: Python :: 3.10",
|
|
30
|
+
"Programming Language :: Python :: 3.11",
|
|
31
|
+
"Programming Language :: Python :: 3.12",
|
|
32
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
33
|
+
]
|
|
34
|
+
dependencies = [
|
|
35
|
+
"telos-receipt>=0.1.0",
|
|
36
|
+
"mcp>=1.12.0",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[project.optional-dependencies]
|
|
40
|
+
# NOTE: no `engine` extra ships in v0.1. The live governance engine binds in
|
|
41
|
+
# v0.2 via a public, engine-agnostic call surface; until then the adapter fails
|
|
42
|
+
# closed and no engine dependency is pinned here.
|
|
43
|
+
dev = [
|
|
44
|
+
"pytest>=8.0",
|
|
45
|
+
"ruff>=0.5",
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
[project.urls]
|
|
49
|
+
Homepage = "https://telos-labs.ai"
|
|
50
|
+
Repository = "https://github.com/TELOS-Labs-AI/telos-mcp"
|
|
51
|
+
Issues = "https://github.com/TELOS-Labs-AI/telos-mcp/issues"
|
|
52
|
+
Documentation = "https://github.com/TELOS-Labs-AI/telos-mcp#readme"
|
|
53
|
+
|
|
54
|
+
[project.scripts]
|
|
55
|
+
telos-mcp = "telos_mcp.server:main"
|
|
56
|
+
|
|
57
|
+
[tool.hatch.build.targets.wheel]
|
|
58
|
+
packages = ["telos_mcp"]
|
|
59
|
+
|
|
60
|
+
[tool.hatch.build.targets.sdist]
|
|
61
|
+
only-include = ["telos_mcp", "README.md", "LICENSE", "pyproject.toml", "server.json"]
|
|
62
|
+
|
|
63
|
+
[tool.ruff]
|
|
64
|
+
line-length = 100
|
|
65
|
+
target-version = "py310"
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "ai.telos-labs/telos-mcp",
|
|
4
|
+
"title": "TELOS Governance",
|
|
5
|
+
"description": "Governance infrastructure for AI agents over MCP. Score proposed actions against a Purpose Anchor, verify unsigned integrity-hash receipts offline (key-free; not a signature check), inspect compiled governance centroids, query the append-only audit chain, and queue CCRS counterfactual replays. v0.1 ships with stubbed engine calls; v0.2 wires the telos-gov engine.",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"url": "https://github.com/TELOS-Labs-AI/telos-mcp",
|
|
9
|
+
"source": "github"
|
|
10
|
+
},
|
|
11
|
+
"packages": [
|
|
12
|
+
{
|
|
13
|
+
"registryType": "pypi",
|
|
14
|
+
"registryBaseUrl": "https://pypi.org",
|
|
15
|
+
"identifier": "telos-mcp",
|
|
16
|
+
"version": "0.1.0",
|
|
17
|
+
"runtimeHint": "uvx",
|
|
18
|
+
"transport": {
|
|
19
|
+
"type": "stdio"
|
|
20
|
+
},
|
|
21
|
+
"environmentVariables": [
|
|
22
|
+
{
|
|
23
|
+
"name": "TELOS_AGENT_ID",
|
|
24
|
+
"description": "Default agent_id used when an MCP client does not pass one explicitly. Optional for v0.1 (stub mode); required once the telos-gov engine is wired in v0.2.",
|
|
25
|
+
"isRequired": false,
|
|
26
|
+
"isSecret": false
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""telos-mcp: Model Context Protocol server for TELOS AI Labs governance.
|
|
2
|
+
|
|
3
|
+
Exposes TELOS governance primitives (scoring, receipt verification, Purpose
|
|
4
|
+
Anchor inspection, audit chain access, and CCRS counterfactual replay) over
|
|
5
|
+
the Model Context Protocol so any MCP-compatible client (Claude Desktop,
|
|
6
|
+
Claude Code, Cursor, Cline, etc.) can call them as native tools.
|
|
7
|
+
|
|
8
|
+
This package is a thin protocol adapter. The governance engine binds in v0.2
|
|
9
|
+
via a public, engine-agnostic call surface. v0.1 ships with stubbed engine
|
|
10
|
+
calls so the protocol surface can be exercised end-to-end without an installed
|
|
11
|
+
engine; v0.2 replaces the stubs with live calls.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
__version__ = "0.1.0"
|
|
15
|
+
__all__ = ["__version__"]
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""Engine dispatcher for telos-mcp (v0.2 scaffold).
|
|
2
|
+
|
|
3
|
+
Selects which engine backs the MCP tool surface, behind a feature flag:
|
|
4
|
+
|
|
5
|
+
TELOS_MCP_ENGINE = stub (default, and the value when unset) -> engine_stub
|
|
6
|
+
TELOS_MCP_ENGINE = real -> engine_real
|
|
7
|
+
|
|
8
|
+
Flag OFF (stub) is byte-identical to v0.1: `active_engine()` returns the
|
|
9
|
+
`engine_stub` module object itself, so every call is literally the same function
|
|
10
|
+
v0.1 called. No indirection changes the output.
|
|
11
|
+
|
|
12
|
+
Flag ON (real) loads the real-engine adapter lazily. The adapter guarded-imports
|
|
13
|
+
the governance engine; if the engine is not installed, this FAILS CLOSED with a
|
|
14
|
+
clear, catchable `EngineUnavailable` rather than crashing on import or silently
|
|
15
|
+
falling back to the stub. Public install and the test suite never touch the real
|
|
16
|
+
engine because the import is lazy and only happens when the flag is explicitly
|
|
17
|
+
set to `real`.
|
|
18
|
+
|
|
19
|
+
This is a scaffold: the `real` path is wired but dormant. It does NOT become the
|
|
20
|
+
default and does NOT add a hard dependency. See engine_real.py for the seam.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
from __future__ import annotations
|
|
24
|
+
|
|
25
|
+
import os
|
|
26
|
+
from types import ModuleType
|
|
27
|
+
|
|
28
|
+
ENGINE_ENV = "TELOS_MCP_ENGINE"
|
|
29
|
+
_STUB_VALUES = {"", "stub", "off", "0", "false", "no"}
|
|
30
|
+
_REAL_VALUES = {"real", "on", "1", "true", "yes"}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class EngineConfigError(RuntimeError):
|
|
34
|
+
"""The TELOS_MCP_ENGINE flag held an unrecognized value."""
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class EngineUnavailable(RuntimeError):
|
|
38
|
+
"""The real engine was requested but is not installed/wired (fail closed)."""
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def engine_mode() -> str:
|
|
42
|
+
"""Return the normalized flag value: 'stub' or 'real'."""
|
|
43
|
+
raw = os.environ.get(ENGINE_ENV, "").strip().lower()
|
|
44
|
+
if raw in _STUB_VALUES:
|
|
45
|
+
return "stub"
|
|
46
|
+
if raw in _REAL_VALUES:
|
|
47
|
+
return "real"
|
|
48
|
+
raise EngineConfigError(
|
|
49
|
+
f"unrecognized {ENGINE_ENV}={raw!r}; expected one of "
|
|
50
|
+
f"{sorted(_STUB_VALUES | _REAL_VALUES)}"
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def active_engine() -> ModuleType:
|
|
55
|
+
"""Return the engine module providing the v0.1 call surface.
|
|
56
|
+
|
|
57
|
+
Stub mode returns the `engine_stub` module object unchanged (byte-identical
|
|
58
|
+
to v0.1). Real mode loads and returns the real adapter, or fails closed.
|
|
59
|
+
"""
|
|
60
|
+
if engine_mode() == "stub":
|
|
61
|
+
from telos_mcp import engine_stub # local import keeps the module graph flat
|
|
62
|
+
return engine_stub
|
|
63
|
+
from telos_mcp import engine_real
|
|
64
|
+
return engine_real.load()
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""Real-engine adapter for telos-mcp (v0.2 scaffold; DORMANT).
|
|
2
|
+
|
|
3
|
+
This module is the seam where the live TELOS governance engine plugs in. It is
|
|
4
|
+
present so the dispatch path exists and is tested, but it is dormant: it adds no
|
|
5
|
+
hard dependency and is only reached when `TELOS_MCP_ENGINE=real` is set
|
|
6
|
+
explicitly.
|
|
7
|
+
|
|
8
|
+
Importing this module does NOT import the governance engine. The guarded import
|
|
9
|
+
happens inside `load()`, so `from telos_mcp import engine_real` always succeeds,
|
|
10
|
+
public install stays clean, and the test suite passes with no engine installed.
|
|
11
|
+
|
|
12
|
+
Dependency note: the live governance engine binds in v0.2 via the public,
|
|
13
|
+
engine-agnostic call surface. Until then `load()` fails closed and no engine
|
|
14
|
+
dependency is imported or pinned.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
from types import ModuleType
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def load() -> ModuleType:
|
|
23
|
+
"""Load the real engine adapter, or fail closed.
|
|
24
|
+
|
|
25
|
+
Returns a module-like object exposing the same call surface as
|
|
26
|
+
`engine_stub` (score_action, verify_receipt, get_pa, audit_window,
|
|
27
|
+
queue_replay, read_wiki_page, read_centroids, read_audit_segment).
|
|
28
|
+
|
|
29
|
+
Raises:
|
|
30
|
+
EngineUnavailable: the real engine is not installed/wired. This is the
|
|
31
|
+
expected state in the scaffold; the dispatcher surfaces it cleanly so
|
|
32
|
+
callers never see a hard ImportError or a silent stub fallback.
|
|
33
|
+
"""
|
|
34
|
+
from telos_mcp.engine import EngineUnavailable
|
|
35
|
+
|
|
36
|
+
try:
|
|
37
|
+
# Guarded import of the real engine. Absent in the scaffold; present
|
|
38
|
+
# only once the clean-facade engine is installed and explicitly opted in.
|
|
39
|
+
import telos_gov # type: ignore # noqa: F401
|
|
40
|
+
except ImportError as exc:
|
|
41
|
+
raise EngineUnavailable(
|
|
42
|
+
"real engine requested (TELOS_MCP_ENGINE=real) but the governance "
|
|
43
|
+
"engine is not installed/wired. The v0.2 scaffold is dormant; the "
|
|
44
|
+
"real engine binds after the clean-facade republish. Unset "
|
|
45
|
+
"TELOS_MCP_ENGINE to use the stub."
|
|
46
|
+
) from exc
|
|
47
|
+
|
|
48
|
+
# Reached only when a real engine is installed. The binding below is left as
|
|
49
|
+
# the documented swap point so the scaffold neither imports private symbols
|
|
50
|
+
# nor claims behavior it does not yet have.
|
|
51
|
+
raise EngineUnavailable(
|
|
52
|
+
"governance engine present but the real adapter binding is not enabled "
|
|
53
|
+
"in this scaffold build; binding lands with the clean-facade engine."
|
|
54
|
+
)
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"""Stubbed TELOS engine calls for telos-mcp.
|
|
2
|
+
|
|
3
|
+
These functions return realistic-shaped placeholder data so MCP clients can
|
|
4
|
+
exercise the full protocol surface (tools, resources, prompts) without an
|
|
5
|
+
installed governance engine. Every stub carries a TODO marker showing where
|
|
6
|
+
the real `telos_gov` call replaces it.
|
|
7
|
+
|
|
8
|
+
Receipts use the shared `telos-receipt` contract: when the scorer scores an
|
|
9
|
+
action it mints an UNSIGNED integrity-hash receipt (a key-free SHA-256 over the
|
|
10
|
+
canonical payload; `signature: null`, `signing_status:
|
|
11
|
+
"unsigned_integrity_hash"`). It is the exact envelope the telos-trust-surface
|
|
12
|
+
serves and verifies, so a receipt minted here verifies there unchanged.
|
|
13
|
+
|
|
14
|
+
Going live is two internal flips, no schema break:
|
|
15
|
+
- Engine: stub -> real. Add `telos-gov` as a hard dependency and route
|
|
16
|
+
score/verify/get_pa/audit/replay through the real engine (the dispatcher
|
|
17
|
+
in engine.py already gates this on TELOS_MCP_ENGINE=real). The receipt
|
|
18
|
+
payload becomes real verdicts/scores instead of synthetic ones.
|
|
19
|
+
- Signer: null -> real. A real signature fills the receipt's `signature`
|
|
20
|
+
field and `signing_status` flips. Every field already exists.
|
|
21
|
+
|
|
22
|
+
Stub determinism: every return value is constructed deterministically from
|
|
23
|
+
the inputs so test snapshots stay stable across runs. No hidden randomness.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
from __future__ import annotations
|
|
27
|
+
|
|
28
|
+
import hashlib
|
|
29
|
+
import json
|
|
30
|
+
from datetime import datetime, timedelta, timezone
|
|
31
|
+
from typing import Any
|
|
32
|
+
|
|
33
|
+
import telos_receipt
|
|
34
|
+
|
|
35
|
+
# Labels the engine that produced a receipt payload. Honest about stub state:
|
|
36
|
+
# the scores are synthetic and the receipt is unsigned until the engine + signer
|
|
37
|
+
# are wired (see module docstring).
|
|
38
|
+
STUB_ENGINE = "telos-mcp v0.1 stub (governance engine not wired; unsigned integrity-hash)"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
# -- Verdict + dimension constants -----------------------------------------
|
|
42
|
+
|
|
43
|
+
VERDICTS = ("EXECUTE", "CLARIFY", "ESCALATE")
|
|
44
|
+
DIMENSIONS = ("purpose", "scope", "boundary", "tool", "chain", "codebase_fidelity")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _digest(payload: Any) -> str:
|
|
48
|
+
"""Stable SHA-256 digest used for deterministic stub IDs."""
|
|
49
|
+
blob = json.dumps(payload, sort_keys=True, default=str).encode("utf-8")
|
|
50
|
+
return hashlib.sha256(blob).hexdigest()
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _now_iso() -> str:
|
|
54
|
+
return datetime.now(timezone.utc).isoformat(timespec="seconds")
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
# -- Tool: telos_score -----------------------------------------------------
|
|
58
|
+
|
|
59
|
+
def score_action(action_name: str, action_params: dict[str, Any], agent_id: str) -> dict[str, Any]:
|
|
60
|
+
"""Score a proposed action against the active Purpose Anchor.
|
|
61
|
+
|
|
62
|
+
Mints an unsigned integrity-hash receipt (shared telos-receipt contract)
|
|
63
|
+
committing to the governance result. The receipt verifies on the
|
|
64
|
+
telos-trust-surface unchanged.
|
|
65
|
+
|
|
66
|
+
TODO: replace the synthetic scoring below with `telos_gov.score_action(...)`.
|
|
67
|
+
Keep `build_action_receipt(...)` as the receipt mint point; only the verdict
|
|
68
|
+
and scores change from synthetic to real, and the signer fills `signature`.
|
|
69
|
+
"""
|
|
70
|
+
digest = _digest({"action": action_name, "params": action_params, "agent": agent_id})
|
|
71
|
+
# Synthetic, illustrative scores (NOT real calibration) derived from the
|
|
72
|
+
# digest for stub stability. The floor/span constants are arbitrary fixture
|
|
73
|
+
# values; they are not the engine's calibration.
|
|
74
|
+
seed = int(digest[:8], 16)
|
|
75
|
+
raw = [(seed >> (i * 5)) & 0xFF for i in range(len(DIMENSIONS))]
|
|
76
|
+
scores = {dim: round(0.1234 + (raw[i] / 255.0) * 0.4321, 4) for i, dim in enumerate(DIMENSIONS)}
|
|
77
|
+
composite = round(sum(scores.values()) / len(scores), 4)
|
|
78
|
+
# Stub verdict is a deterministic FIXTURE rotation keyed off the digest,
|
|
79
|
+
# chosen structurally independent of the scores. The real engine's method for
|
|
80
|
+
# mapping a score to a verdict is deliberately NOT represented in this public
|
|
81
|
+
# stub: no public threshold gates the verdict here.
|
|
82
|
+
verdict = VERDICTS[int(digest[8:10], 16) % len(VERDICTS)]
|
|
83
|
+
return {
|
|
84
|
+
"verdict": verdict,
|
|
85
|
+
"composite_score": composite,
|
|
86
|
+
"scores": scores,
|
|
87
|
+
"agent_id": agent_id,
|
|
88
|
+
"action_name": action_name,
|
|
89
|
+
"receipt": telos_receipt.build_action_receipt(
|
|
90
|
+
action_name=action_name,
|
|
91
|
+
action_params=action_params,
|
|
92
|
+
agent_id=agent_id,
|
|
93
|
+
verdict=verdict,
|
|
94
|
+
composite_score=composite,
|
|
95
|
+
scores=scores,
|
|
96
|
+
pa_id=f"pa::{agent_id}::v1",
|
|
97
|
+
engine=STUB_ENGINE,
|
|
98
|
+
),
|
|
99
|
+
"stub": True,
|
|
100
|
+
"engine": STUB_ENGINE,
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
# -- Tool: telos_verify ----------------------------------------------------
|
|
105
|
+
|
|
106
|
+
def verify_receipt(receipt_json: str | dict[str, Any]) -> dict[str, Any]:
|
|
107
|
+
"""Verify an unsigned integrity-hash receipt offline.
|
|
108
|
+
|
|
109
|
+
Delegates to the shared `telos-receipt` contract -- the SAME verifier the
|
|
110
|
+
telos-trust-surface runs -- so MCP-side verify and surface-side verify give
|
|
111
|
+
identical answers for the same receipt. Recomputes the integrity hash over
|
|
112
|
+
the receipt payload; it is key-free and is not a signature check.
|
|
113
|
+
|
|
114
|
+
TODO: when the signer is wired, add a real signature check ahead of this
|
|
115
|
+
integrity-hash recompute (the recompute stays as the payload-integrity leg).
|
|
116
|
+
"""
|
|
117
|
+
if isinstance(receipt_json, str):
|
|
118
|
+
try:
|
|
119
|
+
receipt = json.loads(receipt_json)
|
|
120
|
+
except json.JSONDecodeError:
|
|
121
|
+
# Not parseable -> not a dict; the canonical verifier returns a
|
|
122
|
+
# controlled match:False ("receipt is not a JSON object").
|
|
123
|
+
receipt = receipt_json
|
|
124
|
+
else:
|
|
125
|
+
receipt = receipt_json
|
|
126
|
+
return telos_receipt.verify_receipt(receipt)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
# -- Tool: telos_get_pa ----------------------------------------------------
|
|
130
|
+
|
|
131
|
+
def get_pa(agent_id: str) -> dict[str, Any]:
|
|
132
|
+
"""Return the active Purpose Anchor (PA) for an agent.
|
|
133
|
+
|
|
134
|
+
TODO(v0.2): replace with `telos_gov.get_pa(agent_id)`. Real engine
|
|
135
|
+
loads the agent's commissioned PA from the vault.
|
|
136
|
+
"""
|
|
137
|
+
return {
|
|
138
|
+
"agent_id": agent_id,
|
|
139
|
+
"pa_id": f"pa::{agent_id}::v1",
|
|
140
|
+
"purpose": "Demonstrate TELOS governance via MCP (stub PA).",
|
|
141
|
+
"boundaries": [
|
|
142
|
+
"no production system mutation",
|
|
143
|
+
"no PII egress",
|
|
144
|
+
"no execution of unsigned tool calls",
|
|
145
|
+
],
|
|
146
|
+
"scope": ["telos-mcp scaffold", "MCP client integration"],
|
|
147
|
+
"allowed_tools": ["telos_score", "telos_verify", "telos_get_pa", "telos_audit", "telos_replay"],
|
|
148
|
+
"centroid_dimensions": list(DIMENSIONS),
|
|
149
|
+
"compiled_at": _now_iso(),
|
|
150
|
+
"stub": True,
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
# -- Tool: telos_audit -----------------------------------------------------
|
|
155
|
+
|
|
156
|
+
def audit_window(start_iso: str, end_iso: str, cap: int = 100) -> list[dict[str, Any]]:
|
|
157
|
+
"""Return audit-chain entries within a time window (capped).
|
|
158
|
+
|
|
159
|
+
TODO(v0.2): replace with `telos_gov.audit(start, end, limit=cap)` which
|
|
160
|
+
streams from the engine's append-only audit store.
|
|
161
|
+
"""
|
|
162
|
+
# Stub: emit three deterministic entries inside the requested window.
|
|
163
|
+
try:
|
|
164
|
+
start = datetime.fromisoformat(start_iso.replace("Z", "+00:00"))
|
|
165
|
+
end = datetime.fromisoformat(end_iso.replace("Z", "+00:00"))
|
|
166
|
+
# Comparison stays inside the guard: mixed naive/aware inputs raise
|
|
167
|
+
# TypeError here, which -- like an unparseable timestamp -- is bad
|
|
168
|
+
# input the window gracefully treats as empty rather than propagating.
|
|
169
|
+
if end <= start:
|
|
170
|
+
return []
|
|
171
|
+
except (ValueError, TypeError):
|
|
172
|
+
return []
|
|
173
|
+
span = (end - start) / 4
|
|
174
|
+
entries: list[dict[str, Any]] = []
|
|
175
|
+
for i in range(min(3, cap)):
|
|
176
|
+
ts = (start + span * (i + 1)).isoformat(timespec="seconds")
|
|
177
|
+
entries.append({
|
|
178
|
+
"id": f"audit::{_digest({'ts': ts, 'i': i})[:16]}",
|
|
179
|
+
"timestamp": ts,
|
|
180
|
+
"verdict": VERDICTS[i % len(VERDICTS)],
|
|
181
|
+
"agent_id": "stub-agent",
|
|
182
|
+
"action_name": ["read_file", "post_message", "write_file"][i % 3],
|
|
183
|
+
"previous_id": entries[-1]["id"] if entries else None,
|
|
184
|
+
"tkey_fingerprint": "stub:0000000000000000",
|
|
185
|
+
})
|
|
186
|
+
return entries
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
# -- Tool: telos_replay ----------------------------------------------------
|
|
190
|
+
|
|
191
|
+
def queue_replay(receipt_id: str, alt_config_path: str) -> dict[str, Any]:
|
|
192
|
+
"""Queue a CCRS counterfactual replay job; return job id.
|
|
193
|
+
|
|
194
|
+
TODO(v0.2): replace with `telos_gov.replay(receipt_id, alt_config_path)`
|
|
195
|
+
which enqueues the job onto the CCRS Mode C runner.
|
|
196
|
+
"""
|
|
197
|
+
job_id = f"ccrs::{_digest({'receipt': receipt_id, 'cfg': alt_config_path})[:20]}"
|
|
198
|
+
return {
|
|
199
|
+
"job_id": job_id,
|
|
200
|
+
"receipt_id": receipt_id,
|
|
201
|
+
"alt_config_path": alt_config_path,
|
|
202
|
+
"status": "queued",
|
|
203
|
+
"queued_at": _now_iso(),
|
|
204
|
+
"estimated_runtime_seconds": 12,
|
|
205
|
+
"result_uri": f"telos://replay/{job_id}",
|
|
206
|
+
"stub": True,
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
# -- Resource helpers ------------------------------------------------------
|
|
211
|
+
|
|
212
|
+
def read_wiki_page(path: str) -> str:
|
|
213
|
+
"""Resolve a TELOS wiki page by relative path.
|
|
214
|
+
|
|
215
|
+
TODO(v0.2): wire to the governance corpus store and read the actual page
|
|
216
|
+
content (with appropriate read-only access controls).
|
|
217
|
+
"""
|
|
218
|
+
return (
|
|
219
|
+
f"# TELOS Wiki Stub: {path}\n\n"
|
|
220
|
+
"This is a placeholder wiki page returned by telos-mcp v0.1.\n"
|
|
221
|
+
"v0.2 will read the canonical page from the TELOS vault.\n\n"
|
|
222
|
+
f"Requested path: `{path}`\n"
|
|
223
|
+
f"Resolved at: {_now_iso()}\n"
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def read_centroids(dimension: str) -> dict[str, Any]:
|
|
228
|
+
"""Return the compiled centroid set for a governance dimension.
|
|
229
|
+
|
|
230
|
+
TODO(v0.2): wire to the engine's centroid store; centroids are numpy
|
|
231
|
+
arrays compiled from the customer's wiki/docs corpus.
|
|
232
|
+
"""
|
|
233
|
+
if dimension not in DIMENSIONS:
|
|
234
|
+
return {"error": f"unknown dimension: {dimension}", "valid_dimensions": list(DIMENSIONS)}
|
|
235
|
+
return {
|
|
236
|
+
"dimension": dimension,
|
|
237
|
+
"n_centroids": 42,
|
|
238
|
+
"embedding_dim": 17,
|
|
239
|
+
"compiled_from": "stub-corpus",
|
|
240
|
+
"compiled_at": _now_iso(),
|
|
241
|
+
"checksum": _digest({"dim": dimension})[:32],
|
|
242
|
+
"note": "stub: real centroids are float32 arrays loaded from disk",
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
def read_audit_segment(date_str: str) -> list[dict[str, Any]]:
|
|
247
|
+
"""Return the audit chain segment for a given YYYY-MM-DD."""
|
|
248
|
+
try:
|
|
249
|
+
day = datetime.fromisoformat(date_str).replace(tzinfo=timezone.utc)
|
|
250
|
+
except ValueError:
|
|
251
|
+
return []
|
|
252
|
+
return audit_window(
|
|
253
|
+
start_iso=day.isoformat(timespec="seconds"),
|
|
254
|
+
end_iso=(day + timedelta(days=1)).isoformat(timespec="seconds"),
|
|
255
|
+
cap=100,
|
|
256
|
+
)
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"""telos-mcp server: MCP protocol surface for TELOS governance.
|
|
2
|
+
|
|
3
|
+
Exposes 5 tools, 3 resource templates, and 2 prompts via FastMCP. All engine
|
|
4
|
+
calls route through `engine_stub` in v0.1; v0.2 swaps in real `telos-gov`
|
|
5
|
+
calls (see engine_stub.py for the swap protocol).
|
|
6
|
+
|
|
7
|
+
Run:
|
|
8
|
+
python -m telos_mcp.server # stdio transport (Claude Desktop default)
|
|
9
|
+
mcp dev telos_mcp/server.py # dev/inspector mode
|
|
10
|
+
|
|
11
|
+
The module-level `mcp` object is the FastMCP instance; tooling (mcp install,
|
|
12
|
+
mcp dev, ASGI mounts) discovers it by name.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import json
|
|
18
|
+
from typing import Any
|
|
19
|
+
|
|
20
|
+
from mcp.server.fastmcp import FastMCP
|
|
21
|
+
|
|
22
|
+
from telos_mcp import engine
|
|
23
|
+
|
|
24
|
+
# Engine calls route through the dispatcher (engine.py). With the default flag
|
|
25
|
+
# (TELOS_MCP_ENGINE unset / "stub") active_engine() returns the engine_stub
|
|
26
|
+
# module object unchanged -- object identity, so the dispatcher adds no
|
|
27
|
+
# indirection over a direct stub call. Setting the flag to "real" loads the
|
|
28
|
+
# dormant real-engine seam, which fails closed until wired.
|
|
29
|
+
|
|
30
|
+
mcp = FastMCP(
|
|
31
|
+
name="telos-governance",
|
|
32
|
+
instructions=(
|
|
33
|
+
"TELOS governance server. Score proposed agent actions, verify receipts, "
|
|
34
|
+
"inspect Purpose Anchors, query the audit chain, and queue CCRS "
|
|
35
|
+
"counterfactual replays. Returns a verdict in {EXECUTE, CLARIFY, "
|
|
36
|
+
"ESCALATE} for every scored action. The stub engine produces synthetic "
|
|
37
|
+
"scores and UNSIGNED integrity-hash receipts (signature: null, "
|
|
38
|
+
"signing_status: unsigned_integrity_hash) in the shared telos-receipt "
|
|
39
|
+
"envelope; the real engine and a real signer wire in behind the same "
|
|
40
|
+
"shape with no schema break."
|
|
41
|
+
),
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
# =========================================================================
|
|
46
|
+
# Tools
|
|
47
|
+
# =========================================================================
|
|
48
|
+
|
|
49
|
+
@mcp.tool()
|
|
50
|
+
def telos_score(action_name: str, action_params: dict[str, Any], agent_id: str) -> dict[str, Any]:
|
|
51
|
+
"""Score a proposed agent action against the active Purpose Anchor.
|
|
52
|
+
|
|
53
|
+
Returns a verdict (EXECUTE / CLARIFY / ESCALATE) plus a 6-dimension
|
|
54
|
+
score breakdown across purpose, scope, boundary, tool, chain, and
|
|
55
|
+
codebase_fidelity. Each call also mints an unsigned integrity-hash
|
|
56
|
+
receipt (shared telos-receipt envelope) that `telos_verify` -- and the
|
|
57
|
+
telos-trust-surface -- can verify with no translation.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
action_name: Name of the action being proposed (e.g. "write_file").
|
|
61
|
+
action_params: Parameter dict the agent intends to pass to the action.
|
|
62
|
+
agent_id: Stable identifier of the agent proposing the action.
|
|
63
|
+
|
|
64
|
+
Returns:
|
|
65
|
+
Dict with keys: verdict, composite_score, scores, agent_id,
|
|
66
|
+
action_name, receipt, stub, engine.
|
|
67
|
+
"""
|
|
68
|
+
return engine.active_engine().score_action(action_name=action_name, action_params=action_params, agent_id=agent_id)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@mcp.tool()
|
|
72
|
+
def telos_verify(receipt_json: str) -> dict[str, Any]:
|
|
73
|
+
"""Verify an unsigned integrity-hash receipt offline.
|
|
74
|
+
|
|
75
|
+
Recomputes the receipt's integrity hash over its canonical payload using
|
|
76
|
+
the shared telos-receipt contract -- the same verifier the trust surface
|
|
77
|
+
runs -- so the answer matches end-to-end. Key-free; not a signature check.
|
|
78
|
+
|
|
79
|
+
Args:
|
|
80
|
+
receipt_json: The receipt to verify, either as a JSON string or as
|
|
81
|
+
a JSON object (clients may pass either; both are accepted).
|
|
82
|
+
|
|
83
|
+
Returns:
|
|
84
|
+
Dict with keys: match (bool), stated_integrity_hash,
|
|
85
|
+
recomputed_integrity_hash, covered_fields, signing_status, note, reason.
|
|
86
|
+
"""
|
|
87
|
+
return engine.active_engine().verify_receipt(receipt_json)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
@mcp.tool()
|
|
91
|
+
def telos_get_pa(agent_id: str) -> dict[str, Any]:
|
|
92
|
+
"""Return the active Purpose Anchor for an agent.
|
|
93
|
+
|
|
94
|
+
The PA is the governance contract: purpose statement, hard boundaries,
|
|
95
|
+
declared scope, allowed tool list, and the centroid dimensions used to
|
|
96
|
+
score the agent's actions.
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
agent_id: Stable identifier of the agent whose PA to load.
|
|
100
|
+
|
|
101
|
+
Returns:
|
|
102
|
+
Dict with keys: agent_id, pa_id, purpose, boundaries, scope,
|
|
103
|
+
allowed_tools, centroid_dimensions, compiled_at, stub.
|
|
104
|
+
"""
|
|
105
|
+
return engine.active_engine().get_pa(agent_id)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
@mcp.tool()
|
|
109
|
+
def telos_audit(start_iso: str, end_iso: str) -> dict[str, Any]:
|
|
110
|
+
"""Return audit chain entries within a time window.
|
|
111
|
+
|
|
112
|
+
Capped at 100 entries to keep MCP payloads bounded. For deeper queries,
|
|
113
|
+
use the `telos://audit/{date}` resource per-day.
|
|
114
|
+
|
|
115
|
+
Args:
|
|
116
|
+
start_iso: ISO-8601 window start (e.g. "2026-04-25T00:00:00Z").
|
|
117
|
+
end_iso: ISO-8601 window end (must be later than start).
|
|
118
|
+
|
|
119
|
+
Returns:
|
|
120
|
+
Dict with keys: entries (list, max 100), count, capped (bool),
|
|
121
|
+
window {start, end}.
|
|
122
|
+
"""
|
|
123
|
+
# Fetch one past the cap so `capped` reports evidence of truncation (a
|
|
124
|
+
# 101st entry existed), not a count that merely landed on the cap.
|
|
125
|
+
entries = engine.active_engine().audit_window(start_iso=start_iso, end_iso=end_iso, cap=101)
|
|
126
|
+
capped = len(entries) > 100
|
|
127
|
+
entries = entries[:100]
|
|
128
|
+
return {
|
|
129
|
+
"entries": entries,
|
|
130
|
+
"count": len(entries),
|
|
131
|
+
"capped": capped,
|
|
132
|
+
"window": {"start": start_iso, "end": end_iso},
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
@mcp.tool()
|
|
137
|
+
def telos_replay(receipt_id: str, alt_config_path: str) -> dict[str, Any]:
|
|
138
|
+
"""Queue a CCRS counterfactual replay against an alternate config.
|
|
139
|
+
|
|
140
|
+
CCRS Mode C re-runs the lifecycle that produced `receipt_id` under a
|
|
141
|
+
different governance configuration (alt thresholds, alt centroids,
|
|
142
|
+
alt PA) and reports verdict deltas. Returns immediately with a job id;
|
|
143
|
+
poll the result via `telos://replay/{job_id}` once available.
|
|
144
|
+
|
|
145
|
+
Args:
|
|
146
|
+
receipt_id: ID of the receipt to replay against.
|
|
147
|
+
alt_config_path: Path to the alternate config (YAML) to apply.
|
|
148
|
+
|
|
149
|
+
Returns:
|
|
150
|
+
Dict with keys: job_id, receipt_id, alt_config_path, status,
|
|
151
|
+
queued_at, estimated_runtime_seconds, result_uri, stub.
|
|
152
|
+
"""
|
|
153
|
+
return engine.active_engine().queue_replay(receipt_id=receipt_id, alt_config_path=alt_config_path)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
# =========================================================================
|
|
157
|
+
# Resources
|
|
158
|
+
# =========================================================================
|
|
159
|
+
|
|
160
|
+
@mcp.resource("telos://wiki/{path}")
|
|
161
|
+
def wiki_resource(path: str) -> str:
|
|
162
|
+
"""Read a TELOS governance wiki page by relative path.
|
|
163
|
+
|
|
164
|
+
Examples: `telos://wiki/04-governance/architecture/steward-design-spec`
|
|
165
|
+
"""
|
|
166
|
+
return engine.active_engine().read_wiki_page(path)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
@mcp.resource("telos://centroids/{dimension}")
|
|
170
|
+
def centroids_resource(dimension: str) -> str:
|
|
171
|
+
"""Return the compiled centroid set for one governance dimension.
|
|
172
|
+
|
|
173
|
+
Valid dimensions: purpose, scope, boundary, tool, chain, codebase_fidelity.
|
|
174
|
+
Returns a JSON document describing the centroid set (count, embedding
|
|
175
|
+
dim, checksum). Raw float32 arrays are not transported over MCP.
|
|
176
|
+
"""
|
|
177
|
+
return json.dumps(engine.active_engine().read_centroids(dimension), indent=2)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
@mcp.resource("telos://audit/{date}")
|
|
181
|
+
def audit_resource(date: str) -> str:
|
|
182
|
+
"""Return the audit-chain segment for a given YYYY-MM-DD date (UTC)."""
|
|
183
|
+
return json.dumps(engine.active_engine().read_audit_segment(date), indent=2)
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
# =========================================================================
|
|
187
|
+
# Prompts
|
|
188
|
+
# =========================================================================
|
|
189
|
+
|
|
190
|
+
@mcp.prompt()
|
|
191
|
+
def governance_review(action: str) -> str:
|
|
192
|
+
"""User-invokable: have the model review a proposed action for governance fit."""
|
|
193
|
+
return (
|
|
194
|
+
"Review this proposed action for TELOS governance compliance. "
|
|
195
|
+
"Call `telos_score` with the action and inspect the per-dimension "
|
|
196
|
+
"scores. If the verdict is CLARIFY, surface which dimension is "
|
|
197
|
+
"weakest and propose one concrete revision. If ESCALATE, explain "
|
|
198
|
+
"which boundary or scope rule the action crosses.\n\n"
|
|
199
|
+
f"Proposed action:\n{action}"
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
@mcp.prompt()
|
|
204
|
+
def audit_walkthrough(start_date: str, end_date: str) -> str:
|
|
205
|
+
"""User-invokable: walk through the audit chain in a date window."""
|
|
206
|
+
return (
|
|
207
|
+
"Pull the audit-chain entries from "
|
|
208
|
+
f"{start_date} to {end_date} using the `telos_audit` tool. "
|
|
209
|
+
"For each ESCALATE or CLARIFY entry, summarize: what action was "
|
|
210
|
+
"proposed, which agent proposed it, and what the outcome was. "
|
|
211
|
+
"Verify the chain is contiguous (every entry's `previous_id` "
|
|
212
|
+
"matches the prior entry's `id`). Flag any breaks."
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
# =========================================================================
|
|
217
|
+
# Entrypoint
|
|
218
|
+
# =========================================================================
|
|
219
|
+
|
|
220
|
+
def main() -> None:
|
|
221
|
+
"""Console-script entrypoint. Runs the server over stdio (default)."""
|
|
222
|
+
mcp.run()
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
if __name__ == "__main__":
|
|
226
|
+
main()
|