@humanleg/mcp-server 0.0.0-stage → 0.1.1
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/README.md +21 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +151 -0
- package/dist/index.js.map +1 -0
- package/package.json +35 -4
package/README.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @humanleg/mcp-server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
MCP server for explicit HumanLeg.ai agent actions.
|
|
4
|
+
|
|
5
|
+
```json
|
|
6
|
+
{
|
|
7
|
+
"mcpServers": {
|
|
8
|
+
"humanleg": {
|
|
9
|
+
"command": "npx",
|
|
10
|
+
"args": ["-y", "@humanleg/mcp-server"],
|
|
11
|
+
"env": {
|
|
12
|
+
"HUMANLEG_API_URL": "http://127.0.0.1:8787",
|
|
13
|
+
"HUMANLEG_AGENT_TOKEN": "sandbox-agent-token"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Funding and publication are separate tools. The server never publishes merely because a task was
|
|
21
|
+
created or approved. Those two tools are hidden by default; expose them only for a synthetic demo by
|
|
22
|
+
setting `HUMANLEG_ENABLE_SETTLEMENT=true`.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { HumanLegApiError, HumanLegClient } from "@humanleg/sdk";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
const baseUrl = process.env.HUMANLEG_API_URL ?? "http://127.0.0.1:8787";
|
|
7
|
+
const token = process.env.HUMANLEG_AGENT_TOKEN;
|
|
8
|
+
if (!token) {
|
|
9
|
+
console.error("HUMANLEG_AGENT_TOKEN is required. Use only a sandbox token in local demos.");
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
const client = new HumanLegClient({ baseUrl, token });
|
|
13
|
+
const server = new McpServer({ name: "humanleg", version: "0.1.1" });
|
|
14
|
+
function result(value) {
|
|
15
|
+
return {
|
|
16
|
+
content: [{ type: "text", text: JSON.stringify(value, null, 2) }],
|
|
17
|
+
structuredContent: value,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function failure(error) {
|
|
21
|
+
if (error instanceof HumanLegApiError) {
|
|
22
|
+
return {
|
|
23
|
+
isError: true,
|
|
24
|
+
content: [
|
|
25
|
+
{
|
|
26
|
+
type: "text",
|
|
27
|
+
text: JSON.stringify({ status: error.status, ...error.problem, message: error.message }, null, 2),
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
isError: true,
|
|
34
|
+
content: [
|
|
35
|
+
{
|
|
36
|
+
type: "text",
|
|
37
|
+
text: error instanceof Error ? error.message : "Unknown HumanLeg error",
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
server.registerTool("humanleg_create_fee_quote", {
|
|
43
|
+
title: "Create HumanLeg fee quote",
|
|
44
|
+
description: "Create a short-lived synthetic fee quote before creating a task.",
|
|
45
|
+
inputSchema: {
|
|
46
|
+
rewardUsdc: z
|
|
47
|
+
.number()
|
|
48
|
+
.min(20)
|
|
49
|
+
.describe("Worker reward in synthetic USDC."),
|
|
50
|
+
displayAud: z
|
|
51
|
+
.number()
|
|
52
|
+
.positive()
|
|
53
|
+
.describe("Human-readable AUD equivalent."),
|
|
54
|
+
},
|
|
55
|
+
}, async ({ rewardUsdc, displayAud }) => {
|
|
56
|
+
try {
|
|
57
|
+
return result(await client.createFeeQuote({
|
|
58
|
+
rewardAtomic: Math.round(rewardUsdc * 1_000_000),
|
|
59
|
+
displayAudCents: Math.round(displayAud * 100),
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
return failure(error);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
server.registerTool("humanleg_create_task", {
|
|
67
|
+
title: "Create and review HumanLeg task",
|
|
68
|
+
description: "Create a bounded task and run compliance review. This does not fund or publish the task.",
|
|
69
|
+
inputSchema: {
|
|
70
|
+
feeQuoteId: z.string().uuid(),
|
|
71
|
+
title: z.string().min(3).max(160),
|
|
72
|
+
instructions: z.string().min(10).max(10_000),
|
|
73
|
+
evidenceRequirements: z.array(z.string().min(1)).min(1).max(10),
|
|
74
|
+
rewardUsdc: z.number().min(20),
|
|
75
|
+
displayAud: z.number().positive(),
|
|
76
|
+
deadline: z.string().datetime(),
|
|
77
|
+
},
|
|
78
|
+
}, async (input) => {
|
|
79
|
+
try {
|
|
80
|
+
return result(await client.createTask({
|
|
81
|
+
feeQuoteId: input.feeQuoteId,
|
|
82
|
+
category: "REMOTE_VERIFICATION",
|
|
83
|
+
title: input.title,
|
|
84
|
+
instructions: input.instructions,
|
|
85
|
+
evidenceRequirements: input.evidenceRequirements,
|
|
86
|
+
rewardAtomic: Math.round(input.rewardUsdc * 1_000_000),
|
|
87
|
+
displayAudCents: Math.round(input.displayAud * 100),
|
|
88
|
+
deadline: input.deadline,
|
|
89
|
+
country: "AU",
|
|
90
|
+
physicalPresenceRequired: false,
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
return failure(error);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
server.registerTool("humanleg_get_task", {
|
|
98
|
+
title: "Get HumanLeg task",
|
|
99
|
+
description: "Retrieve the current task, content version, hash and lifecycle status.",
|
|
100
|
+
inputSchema: { taskId: z.string().uuid() },
|
|
101
|
+
}, async ({ taskId }) => {
|
|
102
|
+
try {
|
|
103
|
+
return result(await client.getTask(taskId));
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
return failure(error);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
server.registerTool("humanleg_get_compliance_review", {
|
|
110
|
+
title: "Get HumanLeg compliance review",
|
|
111
|
+
description: "Retrieve the exact-content compliance decision for a task.",
|
|
112
|
+
inputSchema: { taskId: z.string().uuid() },
|
|
113
|
+
}, async ({ taskId }) => {
|
|
114
|
+
try {
|
|
115
|
+
return result(await client.getComplianceReview(taskId));
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
return failure(error);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
if (process.env.HUMANLEG_ENABLE_SETTLEMENT === "true") {
|
|
122
|
+
server.registerTool("humanleg_fund_task", {
|
|
123
|
+
title: "Fund HumanLeg task",
|
|
124
|
+
description: "Create a funding intent for an approved task. Sandbox value only. Funding does not publish.",
|
|
125
|
+
inputSchema: { taskId: z.string().uuid() },
|
|
126
|
+
}, async ({ taskId }) => {
|
|
127
|
+
try {
|
|
128
|
+
return result(await client.createFundingIntent(taskId));
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
return failure(error);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
server.registerTool("humanleg_publish_task", {
|
|
135
|
+
title: "Publish HumanLeg task",
|
|
136
|
+
description: "Explicitly publish a funded task only if its current exact content version remains approved.",
|
|
137
|
+
inputSchema: {
|
|
138
|
+
taskId: z.string().uuid(),
|
|
139
|
+
expectedVersion: z.number().int().positive(),
|
|
140
|
+
},
|
|
141
|
+
}, async ({ taskId, expectedVersion }) => {
|
|
142
|
+
try {
|
|
143
|
+
return result(await client.publishTask(taskId, expectedVersion));
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
return failure(error);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
await server.connect(new StdioServerTransport());
|
|
151
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,uBAAuB,CAAC;AACxE,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;AAC/C,IAAI,CAAC,KAAK,EAAE,CAAC;IACX,OAAO,CAAC,KAAK,CACX,4EAA4E,CAC7E,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;AACtD,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;AAErE,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;QAC1E,iBAAiB,EAAE,KAAgC;KACpD,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,KAAc;IAC7B,IAAI,KAAK,YAAY,gBAAgB,EAAE,CAAC;QACtC,OAAO;YACL,OA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QAC/F,WAAW,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;KAC3C,EACD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;QACnB,IAAI,CAAC;YACH,OAAO,MAAM,CAAC,MAAM,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC;QAC1D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC;IACH,CAAC,CACF,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,uBAAuB,EACvB;QACE,KAAK,EAAE,uBAAuB;QAC9B,WAAW,EACT,8FAA8F;QAChG,WAAW,EAAE;YACX,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;YACzB,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;SAC7C;KACF,EACD,KAAK,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,EAAE,EAAE;QACpC,IAAI,CAAC;YACH,OAAO,MAAM,CAAC,MAAM,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC;QACnE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@humanleg/mcp-server",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"mcpName": "io.github.humanleg-ai/humanleg",
|
|
5
|
+
"description": "MCP server that lets AI agents hand bounded tasks to HumanLeg.ai.",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc -p tsconfig.json",
|
|
15
|
+
"start": "node dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"bin": {
|
|
18
|
+
"humanleg-mcp": "dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@humanleg/sdk": "0.1.0",
|
|
22
|
+
"@modelcontextprotocol/sdk": "^1.24.3",
|
|
23
|
+
"zod": "^4.1.13"
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/humanleg-ai/humanleg.git",
|
|
28
|
+
"directory": "packages/mcp-server"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=20"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public",
|
|
35
|
+
"provenance": true
|
|
36
|
+
}
|
|
37
|
+
}
|