@last-price/tools-mcp 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +46 -2
- package/dist/cli.d.ts +11 -0
- package/dist/cli.js +45 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -0
- package/dist/server.d.ts +41 -0
- package/dist/server.js +93 -0
- package/package.json +51 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 omolade odetara
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,47 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @last-price/tools-mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A stdio [MCP](https://modelcontextprotocol.io) server for Last Price, so Claude Desktop, Claude Code, Cursor
|
|
4
|
+
and other MCP hosts can run it with `npx`. It is a thin client: every tool is a request to the hosted Last Price
|
|
5
|
+
API, built on `@last-price/tools-core`, and it holds no pricing, billing or routing code.
|
|
6
|
+
|
|
7
|
+
If you would rather install nothing, the hosted endpoint is `https://api.last-price.ai/api/mcp/rpc`.
|
|
8
|
+
|
|
9
|
+
## Use it
|
|
10
|
+
|
|
11
|
+
Create an API key in Settings, API keys at https://last-price.ai (without one only the public demo tools work).
|
|
12
|
+
|
|
13
|
+
Claude Code:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
claude mcp add lastprice --env LASTPRICE_API_KEY=lp_xxx -- npx -y @last-price/tools-mcp
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Claude Desktop (`claude_desktop_config.json`) and Cursor (`mcp.json`):
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"mcpServers": {
|
|
24
|
+
"lastprice": {
|
|
25
|
+
"command": "npx",
|
|
26
|
+
"args": ["-y", "@last-price/tools-mcp"],
|
|
27
|
+
"env": { "LASTPRICE_API_KEY": "lp_xxx" }
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
| Variable | Meaning |
|
|
34
|
+
|----------|---------|
|
|
35
|
+
| `LASTPRICE_API_KEY` | Platform API key `lp_...`, sent as `x-api-key`. |
|
|
36
|
+
| `LASTPRICE_JWT` | A JWT instead, sent as `Authorization: Bearer`. |
|
|
37
|
+
| `LASTPRICE_API_URL` | Default `https://api.last-price.ai`. |
|
|
38
|
+
| `LASTPRICE_TIMEOUT_MS` | Time limit per tool call. Default `30000`. |
|
|
39
|
+
| `LASTPRICE_TOOL_ANNOTATIONS` | `1` adds each tool's MCP `annotations` to `tools/list`: a title and `readOnlyHint`, `destructiveHint`, `idempotentHint` and `openWorldHint`, so your host can ask you before a call that changes or deletes something. Off by default. |
|
|
40
|
+
|
|
41
|
+
`tools/list` describes every tool, including which need a credential and a claimed workspace. The same tools are
|
|
42
|
+
listed in the `@last-price/tools-core` README. The annotations are exported from `@last-price/tools-core` as
|
|
43
|
+
`LAST_PRICE_TOOL_ANNOTATIONS`, for frameworks that gate tool calls themselves.
|
|
44
|
+
|
|
45
|
+
## Licence
|
|
46
|
+
|
|
47
|
+
MIT; see [LICENSE](LICENSE).
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Last Price MCP server over stdio (newline-delimited JSON-RPC).
|
|
4
|
+
*
|
|
5
|
+
* LASTPRICE_API_KEY API key `lp_...` from Settings, API keys (optional: without it only demo tools work)
|
|
6
|
+
* LASTPRICE_JWT a JWT instead of a key
|
|
7
|
+
* LASTPRICE_API_URL default https://api.last-price.ai
|
|
8
|
+
* LASTPRICE_TIMEOUT_MS time limit per tool call, default 30000
|
|
9
|
+
* LASTPRICE_TOOL_ANNOTATIONS 1 adds each tool's title and behaviour hints to tools/list
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* Last Price MCP server over stdio (newline-delimited JSON-RPC).
|
|
5
|
+
*
|
|
6
|
+
* LASTPRICE_API_KEY API key `lp_...` from Settings, API keys (optional: without it only demo tools work)
|
|
7
|
+
* LASTPRICE_JWT a JWT instead of a key
|
|
8
|
+
* LASTPRICE_API_URL default https://api.last-price.ai
|
|
9
|
+
* LASTPRICE_TIMEOUT_MS time limit per tool call, default 30000
|
|
10
|
+
* LASTPRICE_TOOL_ANNOTATIONS 1 adds each tool's title and behaviour hints to tools/list
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
const server_1 = require("./server");
|
|
14
|
+
const client = (0, server_1.clientFromEnv)(process.env);
|
|
15
|
+
const options = { annotations: process.env.LASTPRICE_TOOL_ANNOTATIONS === '1' };
|
|
16
|
+
let buffer = '';
|
|
17
|
+
function send(message) {
|
|
18
|
+
process.stdout.write(`${JSON.stringify(message)}\n`);
|
|
19
|
+
}
|
|
20
|
+
async function processLine(line) {
|
|
21
|
+
let parsed;
|
|
22
|
+
try {
|
|
23
|
+
parsed = JSON.parse(line);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
send({ jsonrpc: '2.0', id: null, error: { code: -32700, message: 'Parse error' } });
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const reply = await (0, server_1.handleMessage)(client, parsed, options);
|
|
30
|
+
if (reply)
|
|
31
|
+
send(reply);
|
|
32
|
+
}
|
|
33
|
+
// Decode at the stream level so a multibyte character split across chunks survives.
|
|
34
|
+
process.stdin.setEncoding('utf8');
|
|
35
|
+
process.stdin.on('data', (chunk) => {
|
|
36
|
+
buffer += chunk;
|
|
37
|
+
let newline = buffer.indexOf('\n');
|
|
38
|
+
while (newline >= 0) {
|
|
39
|
+
const line = buffer.slice(0, newline).trim();
|
|
40
|
+
buffer = buffer.slice(newline + 1);
|
|
41
|
+
if (line)
|
|
42
|
+
void processLine(line);
|
|
43
|
+
newline = buffer.indexOf('\n');
|
|
44
|
+
}
|
|
45
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './server';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./server"), exports);
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { LastPriceClient } from '@last-price/tools-core';
|
|
2
|
+
/** Matches `version` in package.json (a test holds the two together). */
|
|
3
|
+
export declare const SERVER_VERSION = "0.1.0";
|
|
4
|
+
/** MCP protocol revisions this server speaks, newest first. */
|
|
5
|
+
export declare const SUPPORTED_PROTOCOLS: readonly ["2025-11-25", "2025-06-18", "2025-03-26", "2024-11-05"];
|
|
6
|
+
export declare const SERVER_INSTRUCTIONS: string;
|
|
7
|
+
export interface JsonRpcMessage {
|
|
8
|
+
jsonrpc?: string;
|
|
9
|
+
id?: string | number | null;
|
|
10
|
+
method?: string;
|
|
11
|
+
params?: unknown;
|
|
12
|
+
}
|
|
13
|
+
export type JsonRpcReply = {
|
|
14
|
+
jsonrpc: '2.0';
|
|
15
|
+
id: string | number | null;
|
|
16
|
+
result: unknown;
|
|
17
|
+
} | {
|
|
18
|
+
jsonrpc: '2.0';
|
|
19
|
+
id: string | number | null;
|
|
20
|
+
error: {
|
|
21
|
+
code: number;
|
|
22
|
+
message: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Answer one JSON-RPC message from an MCP host, or return undefined for a
|
|
27
|
+
* notification (which is never answered). Tool failures come back as a result
|
|
28
|
+
* with `isError`, carrying the API's code and hint so the model can correct
|
|
29
|
+
* its next call.
|
|
30
|
+
*/
|
|
31
|
+
export interface HandleOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Add each tool's MCP `annotations` (title and behaviour hints) to
|
|
34
|
+
* `tools/list`. Off unless set; the CLI sets it from
|
|
35
|
+
* `LASTPRICE_TOOL_ANNOTATIONS=1`.
|
|
36
|
+
*/
|
|
37
|
+
annotations?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export declare function handleMessage(client: LastPriceClient, message: unknown, options?: HandleOptions): Promise<JsonRpcReply | undefined>;
|
|
40
|
+
/** The client the CLI builds from the environment. */
|
|
41
|
+
export declare function clientFromEnv(env: Record<string, string | undefined>): LastPriceClient;
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SERVER_INSTRUCTIONS = exports.SUPPORTED_PROTOCOLS = exports.SERVER_VERSION = void 0;
|
|
4
|
+
exports.handleMessage = handleMessage;
|
|
5
|
+
exports.clientFromEnv = clientFromEnv;
|
|
6
|
+
const tools_core_1 = require("@last-price/tools-core");
|
|
7
|
+
/** Matches `version` in package.json (a test holds the two together). */
|
|
8
|
+
exports.SERVER_VERSION = '0.1.0';
|
|
9
|
+
/** MCP protocol revisions this server speaks, newest first. */
|
|
10
|
+
exports.SUPPORTED_PROTOCOLS = ['2025-11-25', '2025-06-18', '2025-03-26', '2024-11-05'];
|
|
11
|
+
exports.SERVER_INSTRUCTIONS = 'Last Price: compute and verify prices, and manage your pricing workspace. With no credential only the public ' +
|
|
12
|
+
'demo tools work; set LASTPRICE_API_KEY (a key from Settings, API keys at https://last-price.ai) for the rest. ' +
|
|
13
|
+
'Release notes: https://last-price.ai/changelog.';
|
|
14
|
+
const TOOL_NAMES = new Set(tools_core_1.LAST_PRICE_TOOLS.map((tool) => tool.name));
|
|
15
|
+
function failure(id, code, message) {
|
|
16
|
+
return { jsonrpc: '2.0', id, error: { code, message } };
|
|
17
|
+
}
|
|
18
|
+
async function handleMessage(client, message, options = {}) {
|
|
19
|
+
if (message === null || typeof message !== 'object' || Array.isArray(message)) {
|
|
20
|
+
return failure(null, -32600, 'Invalid Request');
|
|
21
|
+
}
|
|
22
|
+
const { id, method, params } = message;
|
|
23
|
+
if (typeof method !== 'string')
|
|
24
|
+
return failure(id ?? null, -32600, 'Invalid Request');
|
|
25
|
+
if (id === undefined)
|
|
26
|
+
return undefined;
|
|
27
|
+
switch (method) {
|
|
28
|
+
case 'initialize': {
|
|
29
|
+
const asked = params?.protocolVersion;
|
|
30
|
+
const protocolVersion = exports.SUPPORTED_PROTOCOLS.includes(asked)
|
|
31
|
+
? asked
|
|
32
|
+
: exports.SUPPORTED_PROTOCOLS[0];
|
|
33
|
+
return {
|
|
34
|
+
jsonrpc: '2.0',
|
|
35
|
+
id,
|
|
36
|
+
result: {
|
|
37
|
+
protocolVersion,
|
|
38
|
+
capabilities: { tools: {} },
|
|
39
|
+
serverInfo: { name: 'last-price', version: exports.SERVER_VERSION },
|
|
40
|
+
instructions: exports.SERVER_INSTRUCTIONS,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
case 'ping':
|
|
45
|
+
return { jsonrpc: '2.0', id, result: {} };
|
|
46
|
+
case 'tools/list':
|
|
47
|
+
return {
|
|
48
|
+
jsonrpc: '2.0',
|
|
49
|
+
id,
|
|
50
|
+
result: {
|
|
51
|
+
tools: tools_core_1.LAST_PRICE_TOOLS.map((tool) => ({
|
|
52
|
+
name: tool.name,
|
|
53
|
+
description: tool.description,
|
|
54
|
+
inputSchema: tool.parameters,
|
|
55
|
+
...(options.annotations ? { annotations: tools_core_1.LAST_PRICE_TOOL_ANNOTATIONS[tool.name] } : {}),
|
|
56
|
+
})),
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
case 'tools/call': {
|
|
60
|
+
const { name, arguments: args } = (params ?? {});
|
|
61
|
+
if (typeof name !== 'string' || !TOOL_NAMES.has(name)) {
|
|
62
|
+
return failure(id, -32602, `Unknown tool: ${String(name)}`);
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
const result = await (0, tools_core_1.runLastPriceTool)(client, name, args ?? {});
|
|
66
|
+
return {
|
|
67
|
+
jsonrpc: '2.0',
|
|
68
|
+
id,
|
|
69
|
+
result: { content: [{ type: 'text', text: JSON.stringify(result) }], isError: false },
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
return {
|
|
74
|
+
jsonrpc: '2.0',
|
|
75
|
+
id,
|
|
76
|
+
result: { content: [{ type: 'text', text: JSON.stringify((0, tools_core_1.toToolError)(error)) }], isError: true },
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
default:
|
|
81
|
+
return failure(id, -32601, `Method not found: ${method}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/** The client the CLI builds from the environment. */
|
|
85
|
+
function clientFromEnv(env) {
|
|
86
|
+
const timeout = Number(env.LASTPRICE_TIMEOUT_MS);
|
|
87
|
+
return new tools_core_1.LastPriceClient({
|
|
88
|
+
apiUrl: env.LASTPRICE_API_URL || 'https://api.last-price.ai',
|
|
89
|
+
apiKey: env.LASTPRICE_API_KEY,
|
|
90
|
+
jwt: env.LASTPRICE_JWT,
|
|
91
|
+
timeoutMs: Number.isFinite(timeout) && timeout > 0 ? timeout : undefined,
|
|
92
|
+
});
|
|
93
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@last-price/tools-mcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A stdio MCP server for the Last Price pricing API, runnable with npx.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://last-price.ai",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/last-price-ai/last-price.git",
|
|
10
|
+
"directory": "packages/tools-mcp"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"email": "support@last-price.ai"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"last-price",
|
|
17
|
+
"pricing",
|
|
18
|
+
"agents",
|
|
19
|
+
"mcp",
|
|
20
|
+
"model-context-protocol"
|
|
21
|
+
],
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"bin": {
|
|
25
|
+
"last-price-mcp": "./dist/cli.js"
|
|
26
|
+
},
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"require": "./dist/index.js",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./package.json": "./package.json"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"README.md",
|
|
38
|
+
"LICENSE"
|
|
39
|
+
],
|
|
40
|
+
"sideEffects": false,
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=20"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public",
|
|
46
|
+
"provenance": true
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@last-price/tools-core": "0.1.0"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json && chmod +x dist/cli.js"
|
|
53
|
+
}
|
|
6
54
|
}
|