@t3ratech/market-pulse-mcp 1.0.0
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/.claude-plugin/marketplace.json +15 -0
- package/.claude-plugin/plugin.json +17 -0
- package/LICENSE +202 -0
- package/NOTICE +24 -0
- package/README.md +132 -0
- package/agent-skills/market-pulse/SKILL.md +79 -0
- package/package.json +63 -0
- package/src/client.js +58 -0
- package/src/config.js +50 -0
- package/src/server.js +147 -0
- package/src/tools.js +12 -0
- package/src/tools.json +693 -0
- package/src/validate.js +35 -0
package/src/server.js
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* T3rnel Market Pulse MCP server.
|
|
4
|
+
*
|
|
5
|
+
* Market Pulse grades the places an autonomous agent can find paid work — bounty
|
|
6
|
+
* boards, agent marketplaces, job feeds — from evidence, and publishes the evidence
|
|
7
|
+
* hash-chained. This server exposes that index to any MCP client over stdio.
|
|
8
|
+
*
|
|
9
|
+
* { "mcpServers": { "market-pulse": {
|
|
10
|
+
* "command": "npx", "args": ["-y", "@t3ratech/market-pulse-mcp"]
|
|
11
|
+
* } } }
|
|
12
|
+
*
|
|
13
|
+
* No key is needed. Set MARKET_PULSE_API_KEY (create one at
|
|
14
|
+
* https://market-pulse.t3ratech.co.zw/account) to raise the daily pull budget and
|
|
15
|
+
* see new job listings sooner. Paid tiers buy delivery capacity, never a grade.
|
|
16
|
+
*/
|
|
17
|
+
import { createInterface } from "node:readline";
|
|
18
|
+
import { createRequire } from "node:module";
|
|
19
|
+
import { realpathSync } from "node:fs";
|
|
20
|
+
import { fileURLToPath } from "node:url";
|
|
21
|
+
import { TOOLS, findTool } from "./tools.js";
|
|
22
|
+
import { loadConfig, ConfigError } from "./config.js";
|
|
23
|
+
import { createClient, RemoteError } from "./client.js";
|
|
24
|
+
import { validateToolArgs } from "./validate.js";
|
|
25
|
+
|
|
26
|
+
const require = createRequire(import.meta.url);
|
|
27
|
+
export const { version: SERVER_VERSION } = require("../package.json");
|
|
28
|
+
export const SERVER_NAME = "market-pulse";
|
|
29
|
+
const SUPPORTED_PROTOCOLS = ["2025-06-18", "2025-03-26", "2024-11-05"];
|
|
30
|
+
|
|
31
|
+
const INSTRUCTIONS =
|
|
32
|
+
"Market Pulse is an evidence-backed index of where autonomous agents can find paid work. " +
|
|
33
|
+
"Start with pulse_lanes to shortlist lanes, call pulse_should_i_bid before committing effort to one, " +
|
|
34
|
+
"and read pulse_evidence to verify a grade. All tools are read-only and work without a key on the free tier; " +
|
|
35
|
+
"Unknown is a valid answer and means unmeasured, not failed. Call pulse_account to see the tier and daily quota.";
|
|
36
|
+
|
|
37
|
+
function refusal(text) {
|
|
38
|
+
return { content: [{ type: "text", text }], isError: true };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function createServer({ client, tools = TOOLS }) {
|
|
42
|
+
async function callTool(params) {
|
|
43
|
+
const tool = tools.find(t => t.name === params?.name);
|
|
44
|
+
if (!tool) {
|
|
45
|
+
return { error: { code: -32602, message: `unknown tool: ${params?.name}. Available: ${tools.map(t => t.name).join(", ")}` } };
|
|
46
|
+
}
|
|
47
|
+
const args = params.arguments ?? {};
|
|
48
|
+
const invalid = validateToolArgs(tool, args);
|
|
49
|
+
if (invalid) return { result: refusal(invalid) };
|
|
50
|
+
try {
|
|
51
|
+
return { result: await client.callTool(tool.name, args) };
|
|
52
|
+
} catch (error) {
|
|
53
|
+
if (error instanceof RemoteError) return { result: refusal(error.message) };
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function handleOne(message) {
|
|
59
|
+
if (!message || message.jsonrpc !== "2.0" || typeof message.method !== "string") {
|
|
60
|
+
return { jsonrpc: "2.0", id: message?.id ?? null, error: { code: -32600, message: "invalid JSON-RPC 2.0 request" } };
|
|
61
|
+
}
|
|
62
|
+
const { id, method, params } = message;
|
|
63
|
+
const isNotification = id === undefined;
|
|
64
|
+
const ok = result => (isNotification ? null : { jsonrpc: "2.0", id, result });
|
|
65
|
+
const fail = (code, text) => (isNotification ? null : { jsonrpc: "2.0", id, error: { code, message: text } });
|
|
66
|
+
switch (method) {
|
|
67
|
+
case "initialize": {
|
|
68
|
+
const asked = params?.protocolVersion;
|
|
69
|
+
return ok({
|
|
70
|
+
protocolVersion: SUPPORTED_PROTOCOLS.includes(asked) ? asked : SUPPORTED_PROTOCOLS[0],
|
|
71
|
+
capabilities: { tools: { listChanged: false } },
|
|
72
|
+
serverInfo: { name: SERVER_NAME, title: "T3rnel Market Pulse", version: SERVER_VERSION },
|
|
73
|
+
instructions: INSTRUCTIONS,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
case "notifications/initialized":
|
|
77
|
+
case "notifications/cancelled":
|
|
78
|
+
return null;
|
|
79
|
+
case "ping":
|
|
80
|
+
return ok({});
|
|
81
|
+
case "tools/list":
|
|
82
|
+
return ok({ tools });
|
|
83
|
+
case "tools/call": {
|
|
84
|
+
const { result, error } = await callTool(params);
|
|
85
|
+
return error ? fail(error.code, error.message) : ok(result);
|
|
86
|
+
}
|
|
87
|
+
default:
|
|
88
|
+
return fail(-32601, `method not found: ${method}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
async handle(message) {
|
|
94
|
+
if (Array.isArray(message)) {
|
|
95
|
+
const replies = (await Promise.all(message.map(handleOne))).filter(r => r !== null);
|
|
96
|
+
return replies.length ? replies : null;
|
|
97
|
+
}
|
|
98
|
+
return handleOne(message);
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export async function main() {
|
|
104
|
+
let config;
|
|
105
|
+
try {
|
|
106
|
+
config = loadConfig();
|
|
107
|
+
} catch (error) {
|
|
108
|
+
if (error instanceof ConfigError) {
|
|
109
|
+
process.stderr.write(`market-pulse-mcp: ${error.message}\n`);
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
const client = createClient({ ...config, userAgent: `market-pulse-mcp/${SERVER_VERSION}` });
|
|
115
|
+
const server = createServer({ client });
|
|
116
|
+
const send = payload => process.stdout.write(`${JSON.stringify(payload)}\n`);
|
|
117
|
+
const reader = createInterface({ input: process.stdin, crlfDelay: Infinity });
|
|
118
|
+
const inFlight = new Set();
|
|
119
|
+
reader.on("line", line => {
|
|
120
|
+
if (!line.trim()) return;
|
|
121
|
+
const work = (async () => {
|
|
122
|
+
let message;
|
|
123
|
+
try {
|
|
124
|
+
message = JSON.parse(line);
|
|
125
|
+
} catch {
|
|
126
|
+
send({ jsonrpc: "2.0", id: null, error: { code: -32700, message: "parse error" } });
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
const reply = await server.handle(message);
|
|
131
|
+
if (reply) send(reply);
|
|
132
|
+
} catch (error) {
|
|
133
|
+
send({ jsonrpc: "2.0", id: message?.id ?? null, error: { code: -32603, message: `internal error: ${error.message}` } });
|
|
134
|
+
}
|
|
135
|
+
})();
|
|
136
|
+
inFlight.add(work);
|
|
137
|
+
work.finally(() => inFlight.delete(work));
|
|
138
|
+
});
|
|
139
|
+
// A client that closes stdin while a call is outstanding still gets its answer.
|
|
140
|
+
reader.on("close", async () => {
|
|
141
|
+
await Promise.allSettled([...inFlight]);
|
|
142
|
+
process.exit(0);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const invokedDirectly = process.argv[1] && realpathSync(process.argv[1]) === fileURLToPath(import.meta.url);
|
|
147
|
+
if (invokedDirectly) await main();
|
package/src/tools.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// The tool definitions are generated from the Market Pulse service's own source by
|
|
2
|
+
// scripts/sync-tools.mjs and committed as tools.json, so this package can answer
|
|
3
|
+
// tools/list with no network (registries introspect a server in a sandbox) and so a
|
|
4
|
+
// drift from the live service is a failing check, not a listing that lies.
|
|
5
|
+
import { readFileSync } from "node:fs";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
|
|
8
|
+
export const TOOLS = JSON.parse(readFileSync(fileURLToPath(new URL("./tools.json", import.meta.url)), "utf8"));
|
|
9
|
+
|
|
10
|
+
export function findTool(name) {
|
|
11
|
+
return TOOLS.find(tool => tool.name === name);
|
|
12
|
+
}
|