@last-price/tools-mcp 0.0.0-stage → 0.2.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 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,48 @@
1
- # Temporary Holding Version
1
+ # @last-price/tools-mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
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
+
40
+ `tools/list` describes every tool, including which need a credential and a claimed workspace, and gives each one its
41
+ MCP `annotations`: a title and `readOnlyHint`, `destructiveHint`, `idempotentHint` and `openWorldHint`, so your host
42
+ can ask you before a call that changes or deletes something. The same tools are
43
+ listed in the `@last-price/tools-core` README. The annotations are exported from `@last-price/tools-core` as
44
+ `LAST_PRICE_TOOL_ANNOTATIONS`, for frameworks that gate tool calls themselves.
45
+
46
+ ## Licence
47
+
48
+ MIT; see [LICENSE](LICENSE).
package/dist/cli.d.ts ADDED
@@ -0,0 +1,10 @@
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
+ */
10
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,43 @@
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
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const server_1 = require("./server");
13
+ const client = (0, server_1.clientFromEnv)(process.env);
14
+ let buffer = '';
15
+ function send(message) {
16
+ process.stdout.write(`${JSON.stringify(message)}\n`);
17
+ }
18
+ async function processLine(line) {
19
+ let parsed;
20
+ try {
21
+ parsed = JSON.parse(line);
22
+ }
23
+ catch {
24
+ send({ jsonrpc: '2.0', id: null, error: { code: -32700, message: 'Parse error' } });
25
+ return;
26
+ }
27
+ const reply = await (0, server_1.handleMessage)(client, parsed);
28
+ if (reply)
29
+ send(reply);
30
+ }
31
+ // Decode at the stream level so a multibyte character split across chunks survives.
32
+ process.stdin.setEncoding('utf8');
33
+ process.stdin.on('data', (chunk) => {
34
+ buffer += chunk;
35
+ let newline = buffer.indexOf('\n');
36
+ while (newline >= 0) {
37
+ const line = buffer.slice(0, newline).trim();
38
+ buffer = buffer.slice(newline + 1);
39
+ if (line)
40
+ void processLine(line);
41
+ newline = buffer.indexOf('\n');
42
+ }
43
+ });
@@ -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);
@@ -0,0 +1,40 @@
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.2.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
+ * Each tool's MCP `annotations` (title and behaviour hints) in
34
+ * `tools/list`. On unless set to false.
35
+ */
36
+ annotations?: boolean;
37
+ }
38
+ export declare function handleMessage(client: LastPriceClient, message: unknown, options?: HandleOptions): Promise<JsonRpcReply | undefined>;
39
+ /** The client the CLI builds from the environment. */
40
+ export declare function clientFromEnv(env: Record<string, string | undefined>): LastPriceClient;
package/dist/server.js ADDED
@@ -0,0 +1,98 @@
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.2.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
+ ...(tool.outputSchema ? { outputSchema: tool.outputSchema } : {}),
56
+ ...(options.annotations === false ? {} : { annotations: tools_core_1.LAST_PRICE_TOOL_ANNOTATIONS[tool.name] }),
57
+ })),
58
+ },
59
+ };
60
+ case 'tools/call': {
61
+ const { name, arguments: args } = (params ?? {});
62
+ if (typeof name !== 'string' || !TOOL_NAMES.has(name)) {
63
+ return failure(id, -32602, `Unknown tool: ${String(name)}`);
64
+ }
65
+ try {
66
+ const result = await (0, tools_core_1.runLastPriceTool)(client, name, args === undefined ? {} : args);
67
+ const text = JSON.stringify(result) ?? 'null';
68
+ const structuredContent = (0, tools_core_1.toolStructuredContent)(name, text);
69
+ return {
70
+ jsonrpc: '2.0',
71
+ id,
72
+ result: { content: [{ type: 'text', text }], isError: false, ...(structuredContent ? { structuredContent } : {}) },
73
+ };
74
+ }
75
+ catch (error) {
76
+ const text = JSON.stringify((0, tools_core_1.toToolError)(error));
77
+ const structuredContent = (0, tools_core_1.toolStructuredContent)(name, text);
78
+ return {
79
+ jsonrpc: '2.0',
80
+ id,
81
+ result: { content: [{ type: 'text', text }], isError: true, ...(structuredContent ? { structuredContent } : {}) },
82
+ };
83
+ }
84
+ }
85
+ default:
86
+ return failure(id, -32601, `Method not found: ${method}`);
87
+ }
88
+ }
89
+ /** The client the CLI builds from the environment. */
90
+ function clientFromEnv(env) {
91
+ const timeout = Number(env.LASTPRICE_TIMEOUT_MS);
92
+ return new tools_core_1.LastPriceClient({
93
+ apiUrl: env.LASTPRICE_API_URL || 'https://api.last-price.ai',
94
+ apiKey: env.LASTPRICE_API_KEY,
95
+ jwt: env.LASTPRICE_JWT,
96
+ timeoutMs: Number.isFinite(timeout) && timeout > 0 ? timeout : undefined,
97
+ });
98
+ }
package/package.json CHANGED
@@ -1,6 +1,54 @@
1
1
  {
2
2
  "name": "@last-price/tools-mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.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.2.0"
50
+ },
51
+ "scripts": {
52
+ "build": "rm -rf dist && tsc -p tsconfig.build.json && chmod +x dist/cli.js"
53
+ }
6
54
  }