@capivv/mcp-server 0.5.53 → 0.5.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { CapivvClient } from '../client.js';
|
|
3
|
+
/**
|
|
4
|
+
* Bayesian posterior as an MCP resource (issue #18 follow-up). Agents
|
|
5
|
+
* that auto-attach matching resources get the experiment's posterior +
|
|
6
|
+
* recommendation in context without an explicit tool call. The list()
|
|
7
|
+
* walks the active experiments so a "list resources" call surfaces one
|
|
8
|
+
* URI per experiment.
|
|
9
|
+
*
|
|
10
|
+
* Companion tools (capivv_get_experiment_posterior, _cuped, _revenue)
|
|
11
|
+
* still cover the what-if + CUPED + revenue paths since those take
|
|
12
|
+
* arguments resources can't express.
|
|
13
|
+
*/
|
|
14
|
+
export declare function registerExperimentPosteriorResource(server: McpServer, client: CapivvClient): void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
/**
|
|
3
|
+
* Bayesian posterior as an MCP resource (issue #18 follow-up). Agents
|
|
4
|
+
* that auto-attach matching resources get the experiment's posterior +
|
|
5
|
+
* recommendation in context without an explicit tool call. The list()
|
|
6
|
+
* walks the active experiments so a "list resources" call surfaces one
|
|
7
|
+
* URI per experiment.
|
|
8
|
+
*
|
|
9
|
+
* Companion tools (capivv_get_experiment_posterior, _cuped, _revenue)
|
|
10
|
+
* still cover the what-if + CUPED + revenue paths since those take
|
|
11
|
+
* arguments resources can't express.
|
|
12
|
+
*/
|
|
13
|
+
export function registerExperimentPosteriorResource(server, client) {
|
|
14
|
+
server.resource('experiment-posterior', new ResourceTemplate('capivv://experiments/{experimentId}/posterior', {
|
|
15
|
+
list: async () => {
|
|
16
|
+
const experiments = await client.listExperiments();
|
|
17
|
+
return {
|
|
18
|
+
resources: experiments.map((e) => ({
|
|
19
|
+
uri: `capivv://experiments/${e.id}/posterior`,
|
|
20
|
+
name: `${e.name} — posterior`,
|
|
21
|
+
description: `Bayesian posterior (P(B>A), expected loss, credible interval, recommendation) for "${e.name}" [${e.status}]`,
|
|
22
|
+
mimeType: 'application/json',
|
|
23
|
+
})),
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
}), { mimeType: 'application/json' }, async (uri, { experimentId }) => {
|
|
27
|
+
const id = Array.isArray(experimentId) ? experimentId[0] : experimentId;
|
|
28
|
+
const posterior = await client.getExperimentPosterior({ experiment_id: id });
|
|
29
|
+
return {
|
|
30
|
+
contents: [
|
|
31
|
+
{
|
|
32
|
+
uri: uri.href,
|
|
33
|
+
text: JSON.stringify(posterior, null, 2),
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
}
|
package/dist/resources/index.js
CHANGED
|
@@ -3,10 +3,12 @@ import { registerRulesResource } from './rules.js';
|
|
|
3
3
|
import { registerConceptsResource } from './concepts.js';
|
|
4
4
|
import { registerQuickstartResource } from './quickstart.js';
|
|
5
5
|
import { registerGuideResources } from './guides.js';
|
|
6
|
+
import { registerExperimentPosteriorResource } from './experiment-posterior.js';
|
|
6
7
|
export function registerAllResources(server, client) {
|
|
7
8
|
registerStatusResource(server, client);
|
|
8
9
|
registerRulesResource(server, client);
|
|
9
10
|
registerConceptsResource(server);
|
|
10
11
|
registerQuickstartResource(server);
|
|
11
12
|
registerGuideResources(server);
|
|
13
|
+
registerExperimentPosteriorResource(server, client);
|
|
12
14
|
}
|