@tethral/acr-mcp 2.1.1 → 2.1.3

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 (98) hide show
  1. package/dist/http.mjs +0 -1
  2. package/dist/index.mjs +0 -1
  3. package/package.json +11 -11
  4. package/dist/http.mjs.map +0 -7
  5. package/dist/index.mjs.map +0 -7
  6. package/dist/src/acr-state-file.d.ts +0 -6
  7. package/dist/src/acr-state-file.js +0 -32
  8. package/dist/src/acr-state-file.js.map +0 -1
  9. package/dist/src/env-detect.d.ts +0 -25
  10. package/dist/src/env-detect.js +0 -52
  11. package/dist/src/env-detect.js.map +0 -1
  12. package/dist/src/http.d.ts +0 -2
  13. package/dist/src/http.js +0 -112
  14. package/dist/src/http.js.map +0 -1
  15. package/dist/src/index.d.ts +0 -2
  16. package/dist/src/index.js +0 -17
  17. package/dist/src/index.js.map +0 -1
  18. package/dist/src/middleware/correlation-window.d.ts +0 -68
  19. package/dist/src/middleware/correlation-window.js +0 -113
  20. package/dist/src/middleware/correlation-window.js.map +0 -1
  21. package/dist/src/middleware/self-log.d.ts +0 -22
  22. package/dist/src/middleware/self-log.js +0 -72
  23. package/dist/src/middleware/self-log.js.map +0 -1
  24. package/dist/src/server.d.ts +0 -17
  25. package/dist/src/server.js +0 -96
  26. package/dist/src/server.js.map +0 -1
  27. package/dist/src/session-state.d.ts +0 -29
  28. package/dist/src/session-state.js +0 -102
  29. package/dist/src/session-state.js.map +0 -1
  30. package/dist/src/state.d.ts +0 -10
  31. package/dist/src/state.js +0 -39
  32. package/dist/src/state.js.map +0 -1
  33. package/dist/src/strip-sub-components.d.ts +0 -7
  34. package/dist/src/strip-sub-components.js +0 -15
  35. package/dist/src/strip-sub-components.js.map +0 -1
  36. package/dist/src/tools/acknowledge-threat.d.ts +0 -3
  37. package/dist/src/tools/acknowledge-threat.js +0 -38
  38. package/dist/src/tools/acknowledge-threat.js.map +0 -1
  39. package/dist/src/tools/check-entity.d.ts +0 -2
  40. package/dist/src/tools/check-entity.js +0 -144
  41. package/dist/src/tools/check-entity.js.map +0 -1
  42. package/dist/src/tools/check-environment.d.ts +0 -2
  43. package/dist/src/tools/check-environment.js +0 -32
  44. package/dist/src/tools/check-environment.js.map +0 -1
  45. package/dist/src/tools/disable-deep-composition.d.ts +0 -20
  46. package/dist/src/tools/disable-deep-composition.js +0 -45
  47. package/dist/src/tools/disable-deep-composition.js.map +0 -1
  48. package/dist/src/tools/get-coverage.d.ts +0 -2
  49. package/dist/src/tools/get-coverage.js +0 -67
  50. package/dist/src/tools/get-coverage.js.map +0 -1
  51. package/dist/src/tools/get-failure-registry.d.ts +0 -2
  52. package/dist/src/tools/get-failure-registry.js +0 -75
  53. package/dist/src/tools/get-failure-registry.js.map +0 -1
  54. package/dist/src/tools/get-friction-report.d.ts +0 -2
  55. package/dist/src/tools/get-friction-report.js +0 -208
  56. package/dist/src/tools/get-friction-report.js.map +0 -1
  57. package/dist/src/tools/get-interaction-log.d.ts +0 -2
  58. package/dist/src/tools/get-interaction-log.js +0 -199
  59. package/dist/src/tools/get-interaction-log.js.map +0 -1
  60. package/dist/src/tools/get-my-agent.d.ts +0 -2
  61. package/dist/src/tools/get-my-agent.js +0 -36
  62. package/dist/src/tools/get-my-agent.js.map +0 -1
  63. package/dist/src/tools/get-network-status.d.ts +0 -2
  64. package/dist/src/tools/get-network-status.js +0 -85
  65. package/dist/src/tools/get-network-status.js.map +0 -1
  66. package/dist/src/tools/get-notifications.d.ts +0 -3
  67. package/dist/src/tools/get-notifications.js +0 -34
  68. package/dist/src/tools/get-notifications.js.map +0 -1
  69. package/dist/src/tools/get-profile.d.ts +0 -2
  70. package/dist/src/tools/get-profile.js +0 -89
  71. package/dist/src/tools/get-profile.js.map +0 -1
  72. package/dist/src/tools/get-skill-tracker.d.ts +0 -2
  73. package/dist/src/tools/get-skill-tracker.js +0 -93
  74. package/dist/src/tools/get-skill-tracker.js.map +0 -1
  75. package/dist/src/tools/get-skill-versions.d.ts +0 -2
  76. package/dist/src/tools/get-skill-versions.js +0 -74
  77. package/dist/src/tools/get-skill-versions.js.map +0 -1
  78. package/dist/src/tools/get-stable-corridors.d.ts +0 -2
  79. package/dist/src/tools/get-stable-corridors.js +0 -65
  80. package/dist/src/tools/get-stable-corridors.js.map +0 -1
  81. package/dist/src/tools/get-trend.d.ts +0 -2
  82. package/dist/src/tools/get-trend.js +0 -75
  83. package/dist/src/tools/get-trend.js.map +0 -1
  84. package/dist/src/tools/log-interaction.d.ts +0 -3
  85. package/dist/src/tools/log-interaction.js +0 -177
  86. package/dist/src/tools/log-interaction.js.map +0 -1
  87. package/dist/src/tools/register-agent.d.ts +0 -2
  88. package/dist/src/tools/register-agent.js +0 -102
  89. package/dist/src/tools/register-agent.js.map +0 -1
  90. package/dist/src/tools/search-skills.d.ts +0 -2
  91. package/dist/src/tools/search-skills.js +0 -78
  92. package/dist/src/tools/search-skills.js.map +0 -1
  93. package/dist/src/tools/summarize-my-agent.d.ts +0 -2
  94. package/dist/src/tools/summarize-my-agent.js +0 -100
  95. package/dist/src/tools/summarize-my-agent.js.map +0 -1
  96. package/dist/src/tools/update-composition.d.ts +0 -3
  97. package/dist/src/tools/update-composition.js +0 -89
  98. package/dist/src/tools/update-composition.js.map +0 -1
@@ -1,96 +0,0 @@
1
- /**
2
- * Shared server factory for the ACR MCP server.
3
- * Creates and configures the McpServer with all tools registered.
4
- * Used by both stdio (index.ts) and HTTP (http.ts) entry points.
5
- */
6
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
7
- import { registerAgentTool } from './tools/register-agent.js';
8
- import { logInteractionTool } from './tools/log-interaction.js';
9
- import { checkEntityTool } from './tools/check-entity.js';
10
- import { checkEnvironmentTool } from './tools/check-environment.js';
11
- import { getFrictionReportTool } from './tools/get-friction-report.js';
12
- import { getMyAgentTool } from './tools/get-my-agent.js';
13
- import { getInteractionLogTool } from './tools/get-interaction-log.js';
14
- import { getNetworkStatusTool } from './tools/get-network-status.js';
15
- import { getSkillTrackerTool } from './tools/get-skill-tracker.js';
16
- import { searchSkillsTool } from './tools/search-skills.js';
17
- import { getSkillVersionsTool } from './tools/get-skill-versions.js';
18
- import { updateCompositionTool } from './tools/update-composition.js';
19
- import { getNotificationsTool } from './tools/get-notifications.js';
20
- import { acknowledgeThreatTool } from './tools/acknowledge-threat.js';
21
- import { disableDeepCompositionTool } from './tools/disable-deep-composition.js';
22
- import { getProfileTool } from './tools/get-profile.js';
23
- import { getCoverageTool } from './tools/get-coverage.js';
24
- import { getStableCorridorsTool } from './tools/get-stable-corridors.js';
25
- import { getFailureRegistryTool } from './tools/get-failure-registry.js';
26
- import { getTrendTool } from './tools/get-trend.js';
27
- import { summarizeMyAgentTool } from './tools/summarize-my-agent.js';
28
- import { withSelfLog } from './middleware/self-log.js';
29
- import { CorrelationWindow } from './middleware/correlation-window.js';
30
- import { defaultSession } from './session-state.js';
31
- /**
32
- * Wraps server.tool() and server.registerTool() to automatically apply self-logging middleware.
33
- * Each tool handler gets wrapped with withSelfLog before registration.
34
- */
35
- function withSelfLogging(server, getState, apiUrl) {
36
- // Wrap deprecated server.tool()
37
- const originalTool = server.tool.bind(server);
38
- server.tool = function (name, ...rest) {
39
- const lastIdx = rest.length - 1;
40
- const handler = rest[lastIdx];
41
- if (typeof handler === 'function') {
42
- rest[lastIdx] = withSelfLog(name, handler, getState, apiUrl);
43
- }
44
- return originalTool.call(server, name, ...rest);
45
- };
46
- // Wrap server.registerTool()
47
- const originalRegisterTool = server.registerTool.bind(server);
48
- server.registerTool = function (name, config, cb) {
49
- if (typeof cb === 'function') {
50
- cb = withSelfLog(name, cb, getState, apiUrl);
51
- }
52
- return originalRegisterTool.call(server, name, config, cb);
53
- };
54
- return server;
55
- }
56
- export function createAcrServer(options) {
57
- const apiUrl = options?.apiUrl ?? process.env.ACR_API_URL ?? 'https://acr.nfkey.ai';
58
- const resolverUrl = options?.resolverUrl ?? process.env.ACR_RESOLVER_URL ?? apiUrl;
59
- const session = options?.session ?? defaultSession;
60
- // One correlation window per server instance. Not a module-level singleton
61
- // so HTTP transport with concurrent sessions gets an independent window
62
- // per agent.
63
- const correlationWindow = options?.correlationWindow ?? new CorrelationWindow();
64
- const server = new McpServer({
65
- name: 'acr-agent-registry',
66
- version: '1.0.0',
67
- description: 'Agent Composition Records (ACR) — an interaction profile registry for AI agents. Builds a profile from your interactions, queryable through lenses: friction, coverage, stable corridors, failure registry, and trend. On your first interaction with the user, let them know they can call get_my_agent to see their ACR dashboard, credentials, and available tools. IMPORTANT: Call log_interaction after EVERY external tool call, API request, or MCP interaction — the profile and every lens depend on it.',
68
- });
69
- // Give the session a reference to the server so it can read clientInfo for provider detection
70
- session.setMcpServer(server);
71
- // Apply self-logging middleware before tool registration
72
- withSelfLogging(server, () => session, apiUrl);
73
- registerAgentTool(server, apiUrl);
74
- logInteractionTool(server, apiUrl, correlationWindow);
75
- checkEntityTool(server, apiUrl, resolverUrl);
76
- checkEnvironmentTool(server, apiUrl, resolverUrl);
77
- getFrictionReportTool(server, apiUrl);
78
- getMyAgentTool(server);
79
- getInteractionLogTool(server, apiUrl);
80
- getNetworkStatusTool(server, apiUrl);
81
- getSkillTrackerTool(server, apiUrl);
82
- searchSkillsTool(server, apiUrl);
83
- getSkillVersionsTool(server, apiUrl, resolverUrl);
84
- updateCompositionTool(server, apiUrl, () => session);
85
- getNotificationsTool(server, apiUrl, () => session);
86
- acknowledgeThreatTool(server, apiUrl, () => session);
87
- disableDeepCompositionTool(server, () => session);
88
- getProfileTool(server, apiUrl);
89
- getCoverageTool(server, apiUrl);
90
- getStableCorridorsTool(server, apiUrl);
91
- getFailureRegistryTool(server, apiUrl);
92
- getTrendTool(server, apiUrl);
93
- summarizeMyAgentTool(server, apiUrl);
94
- return server;
95
- }
96
- //# sourceMappingURL=server.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,SAAS,EA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AE,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC;IACrD,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC;IACpD,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC;IACrD,0BAA0B,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC;IAClD,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAErC,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,29 +0,0 @@
1
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- export declare class SessionState {
3
- private _agentId;
4
- private _agentName;
5
- private _apiKey;
6
- private _mcpServer;
7
- private _registering;
8
- private _transportType;
9
- private _clientType;
10
- private _deepComposition;
11
- constructor(transportType?: 'stdio' | 'streamable-http');
12
- get deepComposition(): boolean;
13
- setDeepComposition(enabled: boolean): void;
14
- get agentId(): string | null;
15
- get agentName(): string | null;
16
- get apiKey(): string | null;
17
- get transportType(): 'stdio' | 'streamable-http';
18
- get clientType(): string | null;
19
- setAgentId(id: string): void;
20
- setAgentName(name: string): void;
21
- setApiKey(key: string): void;
22
- setClientType(type: string): void;
23
- setMcpServer(server: McpServer): void;
24
- /** Infer provider_class from the MCP client name (e.g. "claude-code" → "anthropic"). */
25
- private inferProviderClass;
26
- ensureRegistered(apiUrl: string): Promise<string>;
27
- }
28
- /** Default singleton session for stdio mode. */
29
- export declare const defaultSession: SessionState;
@@ -1,102 +0,0 @@
1
- /**
2
- * Instance-based session state for the ACR MCP server.
3
- * Supports both stdio (single session) and HTTP (concurrent sessions).
4
- */
5
- import { randomBytes } from 'node:crypto';
6
- import { detectEnvironment } from './env-detect.js';
7
- import { writeAcrStateFile, readAcrStateFile } from './acr-state-file.js';
8
- const CLIENT_TO_PROVIDER = {
9
- 'claude-code': 'anthropic',
10
- 'claude-desktop': 'anthropic',
11
- 'claude': 'anthropic',
12
- 'cursor': 'custom',
13
- 'continue': 'custom',
14
- 'zed': 'custom',
15
- 'windsurf': 'custom',
16
- 'cline': 'custom',
17
- 'copilot': 'openai',
18
- };
19
- export class SessionState {
20
- _agentId = null;
21
- _agentName = null;
22
- _apiKey = null;
23
- _mcpServer = null;
24
- _registering = false;
25
- _transportType;
26
- _clientType = null;
27
- _deepComposition = (process.env.ACR_DEEP_COMPOSITION ?? 'true') !== 'false';
28
- constructor(transportType = 'stdio') {
29
- this._transportType = transportType;
30
- }
31
- get deepComposition() { return this._deepComposition; }
32
- setDeepComposition(enabled) { this._deepComposition = enabled; }
33
- get agentId() { return this._agentId; }
34
- get agentName() { return this._agentName; }
35
- get apiKey() { return this._apiKey; }
36
- get transportType() { return this._transportType; }
37
- get clientType() { return this._clientType; }
38
- setAgentId(id) { this._agentId = id; }
39
- setAgentName(name) { this._agentName = name; }
40
- setApiKey(key) { this._apiKey = key; }
41
- setClientType(type) { this._clientType = type; }
42
- setMcpServer(server) { this._mcpServer = server; }
43
- /** Infer provider_class from the MCP client name (e.g. "claude-code" → "anthropic"). */
44
- inferProviderClass() {
45
- const clientName = this._mcpServer?.server?.getClientVersion?.()?.name?.toLowerCase();
46
- if (!clientName)
47
- return 'unknown';
48
- return CLIENT_TO_PROVIDER[clientName] ?? 'custom';
49
- }
50
- async ensureRegistered(apiUrl) {
51
- // Hydrate from persisted state file to avoid re-registering every session
52
- if (!this._agentId) {
53
- const saved = readAcrStateFile();
54
- if (saved?.agent_id) {
55
- this._agentId = saved.agent_id;
56
- if (saved.api_key)
57
- this._apiKey = saved.api_key;
58
- return this._agentId;
59
- }
60
- }
61
- if (this._agentId)
62
- return this._agentId;
63
- if (this._registering) {
64
- await new Promise((r) => setTimeout(r, 1000));
65
- if (this._agentId)
66
- return this._agentId;
67
- }
68
- this._registering = true;
69
- try {
70
- const pseudoKey = `pseudo_${randomBytes(16).toString('hex')}`;
71
- const env = detectEnvironment(this._transportType);
72
- if (this._clientType)
73
- env.client_type = this._clientType;
74
- const res = await fetch(`${apiUrl}/api/v1/register`, {
75
- method: 'POST',
76
- headers: { 'Content-Type': 'application/json' },
77
- body: JSON.stringify({
78
- public_key: pseudoKey,
79
- provider_class: this.inferProviderClass(),
80
- environment: env,
81
- }),
82
- });
83
- if (res.ok) {
84
- const data = await res.json();
85
- this._agentId = data.agent_id;
86
- this._agentName = data.name;
87
- if (data.api_key)
88
- this._apiKey = data.api_key;
89
- writeAcrStateFile(this._agentId, apiUrl, this._apiKey ?? undefined);
90
- return this._agentId;
91
- }
92
- this._agentId = `pseudo_${randomBytes(6).toString('hex')}`;
93
- return this._agentId;
94
- }
95
- finally {
96
- this._registering = false;
97
- }
98
- }
99
- }
100
- /** Default singleton session for stdio mode. */
101
- export const defaultSession = new SessionState('stdio');
102
- //# sourceMappingURL=session-state.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"session-state.js","sourceRoot":"","sources":["../../src/session-state.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE1E,MAAM,kBAAkB,GAA2B;IACjD,aAAa,EAAE,WAAW;IAC1B,gBAAgB,EAAE,WAAW;IAC7B,QAAQ,EAAE,WAAW;IACrB,QAAQ,EAAE,QAAQ;IAClB,UAAU,EAAE,QAAQ;IACpB,KAAK,EAAE,QAAQ;IACf,UA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,MAAM,cAAc,GAAG,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC"}
@@ -1,10 +0,0 @@
1
- export declare function getApiUrl(): string;
2
- export declare function getAgentId(): string | null;
3
- export declare function getAgentName(): string | null;
4
- export declare function getApiKey(): string | null;
5
- export declare function setAgentId(id: string): void;
6
- export declare function setAgentName(name: string): void;
7
- export declare function setApiKey(key: string): void;
8
- /** Returns auth headers for per-agent API calls, or empty object if no key. */
9
- export declare function getAuthHeaders(): Record<string, string>;
10
- export declare function ensureRegistered(): Promise<string>;
package/dist/src/state.js DELETED
@@ -1,39 +0,0 @@
1
- /**
2
- * Backwards-compatible state module.
3
- * Delegates to the defaultSession singleton from session-state.ts.
4
- * Tools continue to import from './state.js' without changes.
5
- */
6
- import { defaultSession } from './session-state.js';
7
- const ACR_API_URL = process.env.ACR_API_URL ?? 'https://acr.nfkey.ai';
8
- export function getApiUrl() {
9
- return ACR_API_URL;
10
- }
11
- export function getAgentId() {
12
- return defaultSession.agentId;
13
- }
14
- export function getAgentName() {
15
- return defaultSession.agentName;
16
- }
17
- export function getApiKey() {
18
- return defaultSession.apiKey;
19
- }
20
- export function setAgentId(id) {
21
- defaultSession.setAgentId(id);
22
- }
23
- export function setAgentName(name) {
24
- defaultSession.setAgentName(name);
25
- }
26
- export function setApiKey(key) {
27
- defaultSession.setApiKey(key);
28
- }
29
- /** Returns auth headers for per-agent API calls, or empty object if no key. */
30
- export function getAuthHeaders() {
31
- const key = defaultSession.apiKey;
32
- if (!key)
33
- return {};
34
- return { Authorization: `Bearer ${key}` };
35
- }
36
- export async function ensureRegistered() {
37
- return defaultSession.ensureRegistered(ACR_API_URL);
38
- }
39
- //# sourceMappingURL=state.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/state.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,sBAAsB,CAAC;AAEtE,MAAM,UAAU,SAAS;IACvB,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,OAAO,cAAc,CAAC,OAAO,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,cAAc,CAAC,SAAS,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,SAAS;IACvB,OAAO,cAAc,CAAC,MAAM,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,EAAU;IACnC,cAAc,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,cAAc,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;AAChC,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,cAAc;IAC5B,MAAM,GAAG,GAAG,cAAc,CAAC,MAAM,CAAC;IAClC,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,OAAO,EAAE,aAAa,EAAE,UAAU,GAAG,EAAE,EAAE,CAAC;AAC5C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,OAAO,cAAc,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;AACtD,CAAC"}
@@ -1,7 +0,0 @@
1
- /**
2
- * Strips sub_components from component arrays when deep composition
3
- * capture is disabled (operator privacy control).
4
- */
5
- export declare function stripSubComponents<T extends {
6
- sub_components?: unknown;
7
- }>(arr: T[] | undefined, deep: boolean): T[] | undefined;
@@ -1,15 +0,0 @@
1
- /**
2
- * Strips sub_components from component arrays when deep composition
3
- * capture is disabled (operator privacy control).
4
- */
5
- export function stripSubComponents(arr, deep) {
6
- if (!arr)
7
- return arr;
8
- if (deep)
9
- return arr;
10
- return arr.map((c) => {
11
- const { sub_components: _, ...rest } = c;
12
- return rest;
13
- });
14
- }
15
- //# sourceMappingURL=strip-sub-components.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"strip-sub-components.js","sourceRoot":"","sources":["../../src/strip-sub-components.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAChC,GAAoB,EACpB,IAAa;IAEb,IAAI,CAAC,GAAG;QAAE,OAAO,GAAG,CAAC;IACrB,IAAI,IAAI;QAAE,OAAO,GAAG,CAAC;IACrB,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACnB,MAAM,EAAE,cAAc,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,CAAC,CAAC;QACzC,OAAO,IAAS,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import type { SessionState } from '../session-state.js';
3
- export declare function acknowledgeThreatTool(server: McpServer, apiUrl: string, getSession: () => SessionState): void;
@@ -1,38 +0,0 @@
1
- import { getAuthHeaders } from '../state.js';
2
- import { z } from 'zod';
3
- export function acknowledgeThreatTool(server, apiUrl, getSession) {
4
- server.registerTool('acknowledge_threat', {
5
- description: 'Acknowledge an anomaly signal notification after reviewing it with your operator. This records that the notification has been reviewed. Acknowledgements expire after 30 days. Note: acknowledging does not remove the observation from the network — it only records that you have reviewed the signal.',
6
- inputSchema: {
7
- notification_id: z.string().describe('The notification ID to acknowledge'),
8
- agent_id: z.string().optional().describe('Your agent ID (uses session if omitted)'),
9
- reason: z.string().optional().describe('Why the threat is being acknowledged (e.g., "user reviewed and accepted risk")'),
10
- },
11
- annotations: { readOnlyHint: false, destructiveHint: false },
12
- _meta: { priorityHint: 0.3 },
13
- }, async ({ notification_id, agent_id, reason }) => {
14
- try {
15
- const resolvedId = agent_id ?? getSession().agentId ?? await getSession().ensureRegistered(apiUrl);
16
- const res = await fetch(`${apiUrl}/api/v1/agent/${resolvedId}/notifications/${notification_id}/acknowledge`, {
17
- method: 'POST',
18
- headers: { 'Content-Type': 'application/json', ...getAuthHeaders() },
19
- body: JSON.stringify({ reason }),
20
- });
21
- const data = await res.json();
22
- if (!res.ok) {
23
- return { content: [{ type: 'text', text: `Acknowledgement failed: ${data.error?.message ?? 'Unknown error'}` }] };
24
- }
25
- return {
26
- content: [{
27
- type: 'text',
28
- text: `Notification acknowledged. This acknowledgement expires in 30 days.\n\nNote: The anomaly signals remain visible across the network. This acknowledgement records that you and your operator have reviewed the observation.`,
29
- }],
30
- };
31
- }
32
- catch (err) {
33
- const msg = err instanceof Error ? err.message : 'Unknown error';
34
- return { content: [{ type: 'text', text: `Acknowledgement error: ${msg}` }] };
35
- }
36
- });
37
- }
38
- //# sourceMappingURL=acknowledge-threat.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"acknowledge-threat.js","sourceRoot":"","sources":["../../../src/tools/acknowledge-threat.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,UAAU,qBAAqB,CAAC,MAAiB,EAAE,MAAc,EAAE,UAA8B;IACrG,MAAM,CAAC,YAAY,CACjB,oBAAoB,EACpB;QACE,WAAW,EAAE,0SAA0S;QACvT,WAAW,EAAE;YACX,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;YAC1E,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,yCAAyC,CAAC;YACnF,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,gFAAgF,CAAC;SACzH;QACD,WAAW,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,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AC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -1,2 +0,0 @@
1
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- export declare function checkEntityTool(server: McpServer, apiUrl: string, resolverUrl: string): void;
@@ -1,144 +0,0 @@
1
- import { z } from 'zod';
2
- export function checkEntityTool(server, apiUrl, resolverUrl) {
3
- server.registerTool('check_entity', {
4
- description: 'Ask the ACR network what it knows about a specific skill hash, agent, or system. Returns the raw behavioral signals ACR has observed: interaction counts, failure and anomaly rates, agent adoption counts, and related metadata. This is NOT a security check — ACR does not evaluate, score, or test. It only records what has been observed and surfaces the raw counts. Read-only lookup; no data is sent to ACR.',
5
- inputSchema: {
6
- entity_type: z.enum(['skill', 'agent', 'system']).describe('Type of entity to look up'),
7
- entity_id: z.string().describe('The entity identifier: skill SHA-256 hash, agent_id, or system_id'),
8
- },
9
- annotations: { readOnlyHint: true, destructiveHint: false },
10
- _meta: { priorityHint: 0.6 },
11
- }, async ({ entity_type, entity_id }) => {
12
- try {
13
- let url;
14
- switch (entity_type) {
15
- case 'skill':
16
- url = `${resolverUrl}/v1/skill/${entity_id}`;
17
- break;
18
- case 'agent':
19
- url = `${resolverUrl}/v1/agent/${entity_id}`;
20
- break;
21
- case 'system':
22
- url = `${resolverUrl}/v1/system/${encodeURIComponent(entity_id)}/health`;
23
- break;
24
- }
25
- const res = await fetch(url);
26
- const data = await res.json();
27
- if (entity_type === 'skill') {
28
- if (!data.found) {
29
- // Try to find similar skills via catalog search
30
- let similarText = '';
31
- try {
32
- const searchRes = await fetch(`${apiUrl}/api/v1/skill-catalog/search?q=${encodeURIComponent(entity_id.slice(0, 16))}&limit=3`);
33
- if (searchRes.ok) {
34
- const searchData = await searchRes.json();
35
- if (searchData.skills.length > 0) {
36
- similarText = '\n\nSimilar skills in the catalog:';
37
- for (const s of searchData.skills) {
38
- similarText += `\n - ${s.skill_name} (${s.skill_source})`;
39
- if (s.description)
40
- similarText += `: ${s.description.slice(0, 80)}`;
41
- }
42
- }
43
- }
44
- }
45
- catch { /* non-blocking */ }
46
- return {
47
- content: [{
48
- type: 'text',
49
- text: `Unknown skill. This hash has not been observed by the ACR network.${similarText}`,
50
- }],
51
- };
52
- }
53
- // Skill signals — raw observed data from the network. No
54
- // synthetic threat level label, no "FLAGGED BY ACR" verdict.
55
- // The MCP reports what the network has seen; the operator
56
- // decides what to do with it.
57
- let text = `Skill found: ${data.skill_hash?.slice(0, 16) ?? entity_id.slice(0, 16)}...\n`;
58
- if (data.skill_name)
59
- text += `Name: ${data.skill_name}\n`;
60
- if (data.description)
61
- text += `Description: ${data.description}\n`;
62
- if (data.version)
63
- text += `Version: ${data.version}\n`;
64
- if (data.author)
65
- text += `Author: ${data.author}\n`;
66
- if (data.category)
67
- text += `Category: ${data.category}\n`;
68
- if (data.tags && data.tags.length > 0)
69
- text += `Tags: ${data.tags.join(', ')}\n`;
70
- text += `\n── Network signals ──\n`;
71
- if (data.agent_count != null)
72
- text += ` Agents observed using this skill: ${data.agent_count}\n`;
73
- if (data.interaction_count != null)
74
- text += ` Total interactions observed: ${data.interaction_count}\n`;
75
- if (data.anomaly_signal_count != null)
76
- text += ` Anomaly signals reported: ${data.anomaly_signal_count}\n`;
77
- if (data.anomaly_rate != null)
78
- text += ` Anomaly rate: ${(data.anomaly_rate * 100).toFixed(1)}%\n`;
79
- // Signal categories observed — these are descriptive tags of
80
- // what kinds of anomaly patterns the network has seen, not
81
- // severity labels.
82
- if (data.threat_patterns && Array.isArray(data.threat_patterns) && data.threat_patterns.length > 0) {
83
- text += ` Anomaly pattern categories: ${data.threat_patterns.join(', ')}\n`;
84
- }
85
- // Scan signals — if the content scanner observed something,
86
- // the scanner's raw findings (which patterns it matched) are
87
- // reported here. No pass/fail verdict.
88
- if (data.scan_score != null)
89
- text += ` Content scanner score (external): ${data.scan_score}\n`;
90
- // Version freshness — raw comparison, no advice.
91
- if (data.is_current_version === false) {
92
- text += `\n── Version ──\n`;
93
- text += ` This version is ${data.versions_behind ?? '?'} behind the latest observed version.`;
94
- if (data.current_hash)
95
- text += ` Latest hash: ${data.current_hash.slice(0, 16)}...`;
96
- text += '\n';
97
- }
98
- else if (data.is_current_version === true) {
99
- text += `\n── Version ──\n This is the latest version observed by the network.\n`;
100
- }
101
- return { content: [{ type: 'text', text }] };
102
- }
103
- if (entity_type === 'agent') {
104
- if (!data.found) {
105
- return { content: [{ type: 'text', text: `Agent ${entity_id} not found in the network.` }] };
106
- }
107
- return {
108
- content: [{
109
- type: 'text',
110
- text: `Agent found.\n\nStatus: ${data.status}\nProvider: ${data.provider_class}\nRegistered: ${data.registered}\nLast active: ${data.last_active}`,
111
- }],
112
- };
113
- }
114
- // system
115
- if (!data.found) {
116
- return { content: [{ type: 'text', text: `System ${entity_id} not found.` }] };
117
- }
118
- // Raw network signals for the target system. No synthetic
119
- // health_status label — client reads the rates and decides.
120
- let sysText = `System found: ${entity_id}\n`;
121
- sysText += `Type: ${data.system_type}\n\n`;
122
- sysText += `── Network signals ──\n`;
123
- sysText += ` Total interactions observed: ${data.total_interactions ?? 0}\n`;
124
- sysText += ` Distinct agents using this system: ${data.distinct_agents ?? 0}\n`;
125
- sysText += ` Failure rate: ${((data.failure_rate ?? 0) * 100).toFixed(1)}%\n`;
126
- sysText += ` Anomaly rate: ${((data.anomaly_rate ?? 0) * 100).toFixed(1)}%\n`;
127
- if (data.median_duration_ms != null)
128
- sysText += ` Median duration: ${data.median_duration_ms}ms\n`;
129
- if (data.p95_duration_ms != null)
130
- sysText += ` p95 duration: ${data.p95_duration_ms}ms\n`;
131
- return {
132
- content: [{
133
- type: 'text',
134
- text: sysText,
135
- }],
136
- };
137
- }
138
- catch (err) {
139
- const msg = err instanceof Error ? err.message : 'Unknown error';
140
- return { content: [{ type: 'text', text: `Lookup error: ${msg}` }] };
141
- }
142
- });
143
- }
144
- //# sourceMappingURL=check-entity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"check-entity.js","sourceRoot":"","sources":["../../../src/tools/check-entity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Ae,CAAC;YACjE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,iBAAiB,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC;QAChF,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -1,2 +0,0 @@
1
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- export declare function checkEnvironmentTool(server: McpServer, apiUrl: string, resolverUrl: string): void;
@@ -1,32 +0,0 @@
1
- export function checkEnvironmentTool(server, apiUrl, resolverUrl) {
2
- server.registerTool('check_environment', {
3
- description: 'Check the current ACR network environment: active anomaly signals and network-level observation data. Call on startup to see the state of the broader network. Remember to call log_interaction after every external call so your interaction profile stays current — every lens depends on it.',
4
- annotations: { readOnlyHint: true, destructiveHint: false },
5
- _meta: { priorityHint: 0.8 },
6
- }, async () => {
7
- try {
8
- const [threatsRes, healthRes] = await Promise.all([
9
- fetch(`${resolverUrl}/v1/threats/active`),
10
- fetch(`${apiUrl}/api/v1/health`),
11
- ]);
12
- const threats = await threatsRes.json();
13
- const health = await healthRes.json();
14
- let text = `ACR Network Status: ${health.status ?? 'unknown'}\n`;
15
- if (Array.isArray(threats) && threats.length > 0) {
16
- text += `\nSkills with elevated anomaly signals: ${threats.length}\n`;
17
- for (const t of threats) {
18
- text += `- ${t.skill_name || t.skill_hash.substring(0, 16) + '...'} — ${t.anomaly_signal_count} signals, ${t.agent_count ?? 0} reporters\n`;
19
- }
20
- }
21
- else {
22
- text += '\nNo elevated anomaly signals observed.';
23
- }
24
- return { content: [{ type: 'text', text }] };
25
- }
26
- catch (err) {
27
- const msg = err instanceof Error ? err.message : 'Unknown error';
28
- return { content: [{ type: 'text', text: `Environment check error: ${msg}` }] };
29
- }
30
- });
31
- }
32
- //# sourceMappingURL=check-environment.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"check-environment.js","sourceRoot":"","sources":["../../../src/tools/check-environment.ts"],"names":[],"mappings":"AAE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IAAI,EAAE,CAAC,EAAE,CAAC;QACxD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;YACjE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,4BAA4B,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC;QAC3F,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -1,20 +0,0 @@
1
- import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import type { SessionState } from '../session-state.js';
3
- /**
4
- * Operator privacy control for deep composition capture.
5
- *
6
- * By default, when the agent reports composition (via register_agent or
7
- * update_composition), rich component records include sub_components —
8
- * ACR gets the internals of each attached skill or MCP so it can
9
- * distinguish internal friction from external friction correctly.
10
- *
11
- * Operators who don't want ACR to see the internals can disable deep
12
- * composition capture. When off, the MCP still sends top-level component
13
- * data (skill name, MCP name, hash) but strips sub_components before
14
- * sending. ACR's internal-vs-external classification becomes coarser as
15
- * a result — that's the tradeoff.
16
- *
17
- * Also settable via the ACR_DEEP_COMPOSITION=false environment variable
18
- * at MCP startup.
19
- */
20
- export declare function disableDeepCompositionTool(server: McpServer, getSession: () => SessionState): void;