Skip to content

ruvnet.

Python

fix(ruvnet): refresh MCP resource freshness on read

rUvd5f7171e79ee
diff --git a/plugins/ruvnet/lib/mcp.mjs b/plugins/ruvnet/lib/mcp.mjs
index 4372aee..e7c398d 100644
--- a/plugins/ruvnet/lib/mcp.mjs
+++ b/plugins/ruvnet/lib/mcp.mjs
@@ -27,7 +27,7 @@ export function dispatch(name, args = {}) {
}
const resources = [
{ uri: 'ruv://catalog', name: 'RuV Stack catalog', mimeType: 'application/json', value: CATALOG },
- { uri: 'ruv://changes', name: 'Reviewed RuV upstream changes', mimeType: 'application/json', value: changes(20) },
+ { uri: 'ruv://changes', name: 'Reviewed RuV upstream changes', mimeType: 'application/json' },
{ uri: 'ruv://federation', name: 'Federation endpoints and authority', mimeType: 'application/json', value: connect('chatgpt') }
];
export function createServer() {
@@ -41,7 +41,7 @@ export function createServer() {
server.setRequestHandler(ReadResourceRequestSchema, async request => {
const r = resources.find(r => r.uri === request.params.uri);
if (!r) throw new Error('Unknown resource URI');
- return { contents: [{ uri: r.uri, mimeType: r.mimeType, text: JSON.stringify(r.value) }] };
+ return { contents: [{ uri: r.uri, mimeType: r.mimeType, text: JSON.stringify(r.uri === 'ruv://changes' ? changes(20) : r.value) }] };
});
server.setRequestHandler(ListPromptsRequestSchema, async () => ({ prompts: [{ name: 'ruvnet-start', description: 'Start a bounded RuV Stack integration', arguments: [{ name: 'goal', description: 'The user-authorized objective', required: true }] }] }));
server.setRequestHandler(GetPromptRequestSchema, async request => {
diff --git a/plugins/ruvnet/test/mcp.test.mjs b/plugins/ruvnet/test/mcp.test.mjs
index bedefa9..146f056 100644
--- a/plugins/ruvnet/test/mcp.test.mjs
+++ b/plugins/ruvnet/test/mcp.test.mjs
@@ -12,7 +12,7 @@ async function exercise(c){
for(const [name,args] of [['ruvnet_discover',{query:'wifi'}],['ruvnet_project',{id:'ruflo'}],['ruvnet_changes',{limit:2}],['ruvnet_plan',{goal:'build harness'}],['ruvnet_connect',{host:'chatgpt'}]]){const r=await c.callTool({name,arguments:args});assert.ok(!r.isError);assert.doesNotThrow(()=>JSON.parse(r.content[0].text));}
const chatgpt=await c.callTool({name:'ruvnet_connect',arguments:{host:'chatgpt'}});assert.equal(JSON.parse(chatgpt.content[0].text).remoteMcp,'https://x.ruv.io/chatgpt/mcp');
for(const [name,args] of [['ruvnet_project',{id:'../../etc/passwd'}],['ruvnet_changes',{limit:21}],['ruvnet_connect',{host:'evil'}],['ruvnet_plan',{}],['ruvnet_discover',{execute:true}],['publish',{}]])assert.equal((await c.callTool({name,arguments:args})).isError,true);
- const rs=await c.listResources();assert.equal(rs.resources.length,3);for(const r of rs.resources)assert.ok((await c.readResource({uri:r.uri})).contents.length);
+ const rs=await c.listResources();assert.equal(rs.resources.length,3);for(const r of rs.resources){const read=await c.readResource({uri:r.uri});assert.ok(read.contents.length);if(r.uri==='ruv://changes'){const value=JSON.parse(read.contents[0].text);assert.ok(['current','stale','clock-skew'].includes(value.freshness.state));assert.match(value.freshness.expiresAt,/Z$/);}}
await assert.rejects(c.readResource({uri:'file:///etc/passwd'}));assert.equal((await c.listPrompts()).prompts[0].name,'ruvnet-start');assert.equal((await c.getPrompt({name:'ruvnet-start',arguments:{goal:'memory'}})).messages[0].role,'user');await assert.rejects(c.getPrompt({name:'other',arguments:{goal:'memory'}}));await assert.rejects(c.getPrompt({name:'ruvnet-start'}));await c.ping();
}
test('official SDK negotiation and protocol errors',async()=>{