toolscript-mcp 0.0.0-stage → 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/LICENSE +22 -0
- package/NOTICE +1 -0
- package/README.md +1284 -2
- package/demo/data.mjs +68 -0
- package/demo/server.mjs +83 -0
- package/dist/host/broker.js +1602 -0
- package/dist/host/main.js +34201 -0
- package/dist/third-party-licenses.txt +397 -0
- package/hints/datadog.md +9 -0
- package/hints/jira.md +6 -0
- package/hints/sha256.json +4 -0
- package/package.json +52 -4
- package/runtime/runner.mjs +329 -0
package/demo/data.mjs
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// The sample data of the demo server: 40 pull requests of a made-up repository. The people, titles and dates are
|
|
2
|
+
// invented. The first task of setup, "Count the open pull requests per author", has the one answer OPEN_BY_AUTHOR,
|
|
3
|
+
// and it needs more than one page of list_pull_requests.
|
|
4
|
+
|
|
5
|
+
export const REPOSITORY = 'example-org/paper-lantern'
|
|
6
|
+
|
|
7
|
+
// [number, author, state, title]
|
|
8
|
+
const ROWS = [
|
|
9
|
+
[1, 'ada', 'open', 'Add a retry to the upload client'],
|
|
10
|
+
[2, 'bruno', 'merged', 'Fix the typo in the install guide'],
|
|
11
|
+
[3, 'chen', 'open', 'Cache the parsed config'],
|
|
12
|
+
[4, 'dara', 'closed', 'Try a new date picker'],
|
|
13
|
+
[5, 'emil', 'open', 'Add a health endpoint'],
|
|
14
|
+
[6, 'farah', 'merged', 'Bump the test runner'],
|
|
15
|
+
[7, 'ada', 'open', 'Split the settings page into tabs'],
|
|
16
|
+
[8, 'bruno', 'open', 'Log the request id on errors'],
|
|
17
|
+
[9, 'chen', 'merged', 'Remove the unused color tokens'],
|
|
18
|
+
[10, 'dara', 'open', 'Add keyboard shortcuts to the editor'],
|
|
19
|
+
[11, 'ada', 'merged', 'Rename the sync job'],
|
|
20
|
+
[12, 'emil', 'open', 'Show the build number in the footer'],
|
|
21
|
+
[13, 'bruno', 'open', 'Validate the email field on blur'],
|
|
22
|
+
[14, 'farah', 'merged', 'Pin the base image'],
|
|
23
|
+
[15, 'chen', 'open', 'Page the audit list'],
|
|
24
|
+
[16, 'ada', 'open', 'Add an empty state to the inbox'],
|
|
25
|
+
[17, 'dara', 'open', 'Trim spaces in search queries'],
|
|
26
|
+
[18, 'bruno', 'merged', 'Fix the flaky export test'],
|
|
27
|
+
[19, 'chen', 'closed', 'Prototype a graph view'],
|
|
28
|
+
[20, 'emil', 'merged', 'Drop the old feature flag'],
|
|
29
|
+
[21, 'ada', 'open', 'Sort tags by name'],
|
|
30
|
+
[22, 'farah', 'open', 'Add alt text to the gallery images'],
|
|
31
|
+
[23, 'bruno', 'open', 'Retry webhooks with backoff'],
|
|
32
|
+
[24, 'chen', 'open', 'Speed up the search index build'],
|
|
33
|
+
[25, 'dara', 'closed', 'Experiment with a sidebar layout'],
|
|
34
|
+
[26, 'ada', 'open', 'Store drafts locally'],
|
|
35
|
+
[27, 'emil', 'open', 'Add a copy button to code blocks'],
|
|
36
|
+
[28, 'bruno', 'open', 'Show relative times in the feed'],
|
|
37
|
+
[29, 'farah', 'merged', 'Update the license year'],
|
|
38
|
+
[30, 'chen', 'open', 'Add a dark theme toggle'],
|
|
39
|
+
[31, 'ada', 'open', 'Warn before leaving with unsaved changes'],
|
|
40
|
+
[32, 'dara', 'open', 'Limit the upload size'],
|
|
41
|
+
[33, 'bruno', 'open', 'Add pagination to the API docs'],
|
|
42
|
+
[34, 'chen', 'merged', 'Fix the broken link in the readme'],
|
|
43
|
+
[35, 'emil', 'merged', 'Clean up the release script'],
|
|
44
|
+
[36, 'farah', 'merged', 'Refresh the screenshots'],
|
|
45
|
+
[37, 'dara', 'open', 'Highlight the active menu item'],
|
|
46
|
+
[38, 'ada', 'open', 'Add a print stylesheet'],
|
|
47
|
+
[39, 'bruno', 'open', 'Add a timeout to the import job'],
|
|
48
|
+
[40, 'chen', 'open', 'Group notifications by day'],
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
const DAY_MS = 86_400_000
|
|
52
|
+
const START = Date.UTC(2026, 0, 5)
|
|
53
|
+
|
|
54
|
+
export const PULL_REQUESTS = ROWS.map(([number, author, state, title]) => ({
|
|
55
|
+
number,
|
|
56
|
+
title,
|
|
57
|
+
author,
|
|
58
|
+
state,
|
|
59
|
+
created_at: new Date(START + number * DAY_MS).toISOString(),
|
|
60
|
+
url: `https://example.com/${REPOSITORY}/pull/${number}`,
|
|
61
|
+
}))
|
|
62
|
+
|
|
63
|
+
/** The answer to "Count the open pull requests per author". */
|
|
64
|
+
export const OPEN_BY_AUTHOR = { ada: 7, bruno: 6, chen: 5, dara: 4, emil: 3, farah: 1 }
|
|
65
|
+
|
|
66
|
+
/** The most pull requests that one page of list_pull_requests returns. */
|
|
67
|
+
export const MAX_PAGE_SIZE = 20
|
|
68
|
+
export const DEFAULT_PAGE_SIZE = 10
|
package/demo/server.mjs
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// A read-only demo MCP server (stdio, one JSON-RPC message per line) over the sample pull requests in data.mjs. It
|
|
2
|
+
// needs no account and no network, so a new setup can try one run_code task. stdout carries only JSON-RPC.
|
|
3
|
+
//
|
|
4
|
+
// node demo/server.mjs
|
|
5
|
+
|
|
6
|
+
import readline from 'node:readline'
|
|
7
|
+
import { DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE, PULL_REQUESTS, REPOSITORY } from './data.mjs'
|
|
8
|
+
|
|
9
|
+
const STATES = ['open', 'closed', 'merged', 'all']
|
|
10
|
+
const READ_ONLY = { readOnlyHint: true }
|
|
11
|
+
|
|
12
|
+
const TOOLS = [
|
|
13
|
+
{
|
|
14
|
+
name: 'list_pull_requests',
|
|
15
|
+
description: `List the pull requests of ${REPOSITORY}, newest number last. Pages of at most ${MAX_PAGE_SIZE}: pass next_cursor as cursor for the next page, until next_cursor is null.`,
|
|
16
|
+
inputSchema: {
|
|
17
|
+
type: 'object',
|
|
18
|
+
properties: {
|
|
19
|
+
state: { type: 'string', enum: STATES, description: 'Default "open".' },
|
|
20
|
+
per_page: { type: 'number', description: `At most ${MAX_PAGE_SIZE} (default ${DEFAULT_PAGE_SIZE}).` },
|
|
21
|
+
cursor: { type: 'string' },
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
annotations: READ_ONLY,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'get_pull_request',
|
|
28
|
+
description: `Get one pull request of ${REPOSITORY} by its number.`,
|
|
29
|
+
inputSchema: { type: 'object', properties: { number: { type: 'number' } }, required: ['number'] },
|
|
30
|
+
annotations: READ_ONLY,
|
|
31
|
+
},
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
const json = value => ({ content: [{ type: 'text', text: JSON.stringify(value) }] })
|
|
35
|
+
const fail = text => ({ content: [{ type: 'text', text }], isError: true })
|
|
36
|
+
|
|
37
|
+
// A cursor is the index of the next pull request in the filtered list, so it stays valid for the fixed data.
|
|
38
|
+
const handlers = {
|
|
39
|
+
list_pull_requests: ({ state = 'open', per_page = DEFAULT_PAGE_SIZE, cursor }) => {
|
|
40
|
+
if (!STATES.includes(state)) return fail(`state must be one of ${STATES.join(', ')}`)
|
|
41
|
+
const size = Math.trunc(Number(per_page))
|
|
42
|
+
if (!(size >= 1 && size <= MAX_PAGE_SIZE)) return fail(`per_page must be a whole number from 1 to ${MAX_PAGE_SIZE}`)
|
|
43
|
+
const start = cursor === undefined ? 0 : Number(cursor)
|
|
44
|
+
const matching = PULL_REQUESTS.filter(pr => state === 'all' || pr.state === state)
|
|
45
|
+
if (!Number.isSafeInteger(start) || start < 0 || start > matching.length) return fail(`unknown cursor: ${cursor}`)
|
|
46
|
+
const end = start + size
|
|
47
|
+
return json({
|
|
48
|
+
pull_requests: matching.slice(start, end),
|
|
49
|
+
next_cursor: end < matching.length ? String(end) : null,
|
|
50
|
+
})
|
|
51
|
+
},
|
|
52
|
+
get_pull_request: ({ number }) => {
|
|
53
|
+
const pr = PULL_REQUESTS.find(p => p.number === number)
|
|
54
|
+
return pr === undefined ? fail(`no pull request ${number} in ${REPOSITORY}`) : json(pr)
|
|
55
|
+
},
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const send = message => process.stdout.write(`${JSON.stringify(message)}\n`)
|
|
59
|
+
|
|
60
|
+
readline.createInterface({ input: process.stdin }).on('line', line => {
|
|
61
|
+
let message
|
|
62
|
+
try {
|
|
63
|
+
message = JSON.parse(line)
|
|
64
|
+
} catch {
|
|
65
|
+
return
|
|
66
|
+
}
|
|
67
|
+
if (message?.id === undefined) return
|
|
68
|
+
const reply = result => send({ jsonrpc: '2.0', id: message.id, result })
|
|
69
|
+
const { method, params } = message
|
|
70
|
+
if (method === 'initialize')
|
|
71
|
+
return reply({
|
|
72
|
+
protocolVersion: params?.protocolVersion ?? '2025-06-18',
|
|
73
|
+
capabilities: { tools: {} },
|
|
74
|
+
serverInfo: { name: 'toolscript-demo', version: '1.0.0' },
|
|
75
|
+
})
|
|
76
|
+
if (method === 'ping') return reply({})
|
|
77
|
+
if (method === 'tools/list') return reply({ tools: TOOLS })
|
|
78
|
+
if (method === 'tools/call') {
|
|
79
|
+
const handler = Object.hasOwn(handlers, params?.name) ? handlers[params.name] : undefined
|
|
80
|
+
return reply(handler ? handler(params.arguments ?? {}) : fail(`unknown tool: ${params?.name}`))
|
|
81
|
+
}
|
|
82
|
+
send({ jsonrpc: '2.0', id: message.id, error: { code: -32601, message: `method not found: ${method}` } })
|
|
83
|
+
})
|