@hasna/cloud 0.1.26 → 0.1.27
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.
- package/dist/mcp/index.js +34 -0
- package/package.json +1 -1
package/dist/mcp/index.js
CHANGED
|
@@ -26059,6 +26059,40 @@ Done. ${results.length} services, ${totalApplied} migrations applied.`);
|
|
|
26059
26059
|
return { content: [{ type: "text", text: lines.join(`
|
|
26060
26060
|
`) }] };
|
|
26061
26061
|
});
|
|
26062
|
+
var mcpAgentRegistry = new Map;
|
|
26063
|
+
server.tool("register_agent", "Register an agent session for attribution", {
|
|
26064
|
+
name: exports_external.string().describe("Agent name"),
|
|
26065
|
+
session_id: exports_external.string().optional().describe("Session identifier")
|
|
26066
|
+
}, async ({ name, session_id }) => {
|
|
26067
|
+
const existing = [...mcpAgentRegistry.values()].find((a) => a.name === name);
|
|
26068
|
+
if (existing) {
|
|
26069
|
+
existing.last_seen_at = new Date().toISOString();
|
|
26070
|
+
return { content: [{ type: "text", text: JSON.stringify({ agent_id: existing.id, name: existing.name, last_seen_at: existing.last_seen_at }) }] };
|
|
26071
|
+
}
|
|
26072
|
+
const id = Math.random().toString(36).slice(2, 10);
|
|
26073
|
+
const agent = { id, name, last_seen_at: new Date().toISOString() };
|
|
26074
|
+
mcpAgentRegistry.set(id, agent);
|
|
26075
|
+
return { content: [{ type: "text", text: JSON.stringify(agent) }] };
|
|
26076
|
+
});
|
|
26077
|
+
server.tool("heartbeat", "Update agent last_seen_at", {
|
|
26078
|
+
agent_id: exports_external.string().optional().describe("Agent ID (optional \u2014 updates by name if registered)")
|
|
26079
|
+
}, async () => {
|
|
26080
|
+
return { content: [{ type: "text", text: `heartbeat at ${new Date().toISOString()}` }] };
|
|
26081
|
+
});
|
|
26082
|
+
server.tool("list_agents", "List registered agents", {}, async () => {
|
|
26083
|
+
const agents = [...mcpAgentRegistry.values()];
|
|
26084
|
+
return { content: [{ type: "text", text: agents.length > 0 ? JSON.stringify(agents) : "No agents registered" }] };
|
|
26085
|
+
});
|
|
26086
|
+
server.tool("set_focus", "Set active project context", {
|
|
26087
|
+
agent_id: exports_external.string().describe("Agent ID"),
|
|
26088
|
+
project_id: exports_external.string().optional().describe("Project to focus on")
|
|
26089
|
+
}, async ({ agent_id, project_id }) => {
|
|
26090
|
+
const agent = mcpAgentRegistry.get(agent_id);
|
|
26091
|
+
if (!agent)
|
|
26092
|
+
return { content: [{ type: "text", text: `Agent not found: ${agent_id}` }], isError: true };
|
|
26093
|
+
agent.project_id = project_id;
|
|
26094
|
+
return { content: [{ type: "text", text: project_id ? `Focus set: ${project_id}` : "Focus cleared" }] };
|
|
26095
|
+
});
|
|
26062
26096
|
async function main() {
|
|
26063
26097
|
const transport = new StdioServerTransport;
|
|
26064
26098
|
await server.connect(transport);
|
package/package.json
CHANGED