@heroku/mcp-server 1.0.7-alpha.1 → 1.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.
@@ -0,0 +1,71 @@
1
+ import { expect } from 'chai';
2
+ import sinon from 'sinon';
3
+ import { setupMcpToolMocks } from './mcp-tool-mocks.spechelper.js';
4
+ describe('setupMcpToolMocks', () => {
5
+ afterEach(() => {
6
+ sinon.restore();
7
+ });
8
+ describe('mock configuration', () => {
9
+ it('should return proper mock structure', () => {
10
+ const mocks = setupMcpToolMocks();
11
+ expect(mocks).to.have.property('server');
12
+ expect(mocks).to.have.property('herokuRepl');
13
+ expect(mocks).to.have.property('getToolCallback');
14
+ expect(mocks.getToolCallback).to.be.a('function');
15
+ });
16
+ });
17
+ describe('callback capture', () => {
18
+ it('should capture callback from 4-argument tool registration', () => {
19
+ const mocks = setupMcpToolMocks();
20
+ const testCallback = async () => ({
21
+ content: [{ type: 'text', text: 'test' }]
22
+ });
23
+ // Simulate 4-argument registration: tool(name, description, schema, callback)
24
+ mocks.server.tool('test_tool', 'Test description', {}, testCallback);
25
+ const capturedCallback = mocks.getToolCallback();
26
+ expect(capturedCallback).to.equal(testCallback);
27
+ });
28
+ it('should find callback when mixed with various non-function arguments', () => {
29
+ const mocks = setupMcpToolMocks();
30
+ const testCallback = async () => ({
31
+ content: [{ type: 'text', text: 'test' }]
32
+ });
33
+ // Simulate registration with different argument types
34
+ mocks.server.tool('test_tool', 'Test description', {}, { readOnlyHint: true }, testCallback);
35
+ const capturedCallback = mocks.getToolCallback();
36
+ expect(capturedCallback).to.equal(testCallback);
37
+ });
38
+ });
39
+ });
40
+ describe('callback capture', () => {
41
+ it('should capture callback from 4-argument tool registration', () => {
42
+ const mocks = setupMcpToolMocks();
43
+ const testCallback = async () => ({
44
+ content: [{ type: 'text', text: 'test' }]
45
+ });
46
+ // Simulate 4-argument registration: tool(name, description, schema, callback)
47
+ mocks.server.tool('test_tool', 'Test description', {}, testCallback);
48
+ const capturedCallback = mocks.getToolCallback();
49
+ expect(capturedCallback).to.equal(testCallback);
50
+ });
51
+ it('should capture callback from 5-argument tool registration', () => {
52
+ const mocks = setupMcpToolMocks();
53
+ const testCallback = async () => ({
54
+ content: [{ type: 'text', text: 'test' }]
55
+ });
56
+ // Simulate 5-argument registration: tool(name, description, schema, options, callback)
57
+ mocks.server.tool('test_tool', 'Test description', {}, {}, testCallback);
58
+ const capturedCallback = mocks.getToolCallback();
59
+ expect(capturedCallback).to.equal(testCallback);
60
+ });
61
+ it('should capture callback from 5-argument tool registration', () => {
62
+ const mocks = setupMcpToolMocks();
63
+ const testCallback = async () => ({
64
+ content: [{ type: 'text', text: 'test' }]
65
+ });
66
+ // Simulate 5-argument registration: tool(name, description, schema, options, callback)
67
+ mocks.server.tool('test_tool', 'Test description', {}, {}, testCallback);
68
+ const capturedCallback = mocks.getToolCallback();
69
+ expect(capturedCallback).to.equal(testCallback);
70
+ });
71
+ });
@@ -0,0 +1,33 @@
1
+ import sinon from 'sinon';
2
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import { HerokuREPL } from '../repl/heroku-cli-repl.js';
4
+ /**
5
+ * Helper function to set up common MCP tool mocks for testing
6
+ * @returns Object containing the server, herokuRepl, and toolCallback for use in tests
7
+ */
8
+ export function setupMcpToolMocks() {
9
+ const server = sinon.createStubInstance(McpServer);
10
+ const herokuRepl = sinon.createStubInstance(HerokuREPL);
11
+ let toolCallback;
12
+ // Create a proper mock for RegisteredTool
13
+ const mockRegisteredTool = {
14
+ enabled: true,
15
+ enable: sinon.stub(),
16
+ disable: sinon.stub(),
17
+ update: sinon.stub(),
18
+ remove: sinon.stub(),
19
+ handler: sinon.stub()
20
+ };
21
+ // Mock the server.tool method - callback is always the last parameter
22
+ server.tool.callsFake((...args) => {
23
+ toolCallback = args[args.length - 1];
24
+ // Update handler to point to the callback
25
+ mockRegisteredTool.handler = toolCallback;
26
+ return mockRegisteredTool;
27
+ });
28
+ return {
29
+ server,
30
+ herokuRepl,
31
+ getToolCallback: () => toolCallback
32
+ };
33
+ }
package/package.json CHANGED
@@ -1,20 +1,19 @@
1
1
  {
2
2
  "name": "@heroku/mcp-server",
3
3
  "description": "Heroku Platform MCP Server",
4
- "version": "1.0.7-alpha.1",
4
+ "version": "1.1.0",
5
5
  "author": "Heroku",
6
6
  "bugs": "https://github.com/heroku/heroku-mcp-server/issues",
7
7
  "bin": {
8
8
  "heroku-mcp-server": "bin/heroku-mcp-server.mjs"
9
9
  },
10
10
  "type": "module",
11
- "main": "dist/index.js",
12
- "module": "dist/index.mjs",
13
- "types": "dist/index.d.ts",
14
11
  "dependencies": {
15
12
  "@heroku/plugin-ai": "^1.0.1",
16
- "@modelcontextprotocol/sdk": "^1.8.0",
13
+ "@modelcontextprotocol/sdk": "^1.16.0",
14
+ "cheerio": "^1.1.0",
17
15
  "jsonschema": "^1.5.0",
16
+ "node-fetch": "^3.3.2",
18
17
  "tar-stream": "^3.1.7",
19
18
  "zod": "^3.24.2",
20
19
  "zod-to-json-schema": "^3.24.5"
@@ -22,7 +21,6 @@
22
21
  "devDependencies": {
23
22
  "@eslint/eslintrc": "^3.3.1",
24
23
  "@eslint/js": "^9.23.0",
25
- "@modelcontextprotocol/inspector": "^0.7.0",
26
24
  "@types/chai": "^5.2.1",
27
25
  "@types/mocha": "^10.0.10",
28
26
  "@types/node": "^20.x",
@@ -36,7 +34,6 @@
36
34
  "eslint-plugin-jsdoc": "^50.6.9",
37
35
  "husky": "^9.1.7",
38
36
  "mocha": "^11.1.0",
39
- "np": "^10.2.0",
40
37
  "nyc": "^17.1.0",
41
38
  "prettier": "^3.5.3",
42
39
  "shx": "^0.4.0",
@@ -48,6 +45,19 @@
48
45
  "engines": {
49
46
  "node": ">=20"
50
47
  },
48
+ "exports": {
49
+ "./*": {
50
+ "import": "./dist/esm/*",
51
+ "require": "./dist/cjs/*"
52
+ }
53
+ },
54
+ "typesVersions": {
55
+ "*": {
56
+ "*": [
57
+ "./dist/esm/*"
58
+ ]
59
+ }
60
+ },
51
61
  "files": [
52
62
  "dist",
53
63
  "bin"
@@ -66,15 +76,16 @@
66
76
  "build": "rm -rf dist && tsc -p tsconfig.json && npm run exec-perms",
67
77
  "build:dev": "rm -rf dist && tsc --sourceMap -p tsconfig.json && npm run exec-perms",
68
78
  "build:watch": "tsc --sourceMap -p tsconfig.json -w",
79
+ "build:dxt": "npx @anthropic-ai/dxt pack",
69
80
  "start:dev": "npm run build:dev && npm link && npx @modelcontextprotocol/inspector heroku-mcp-server",
70
81
  "start": "node dist/index.js",
71
82
  "format": "prettier . --write --config ./.prettier.mjs",
72
83
  "lint": "cd src && eslint ./",
73
84
  "posttest": "npm run lint",
74
- "prepare": "husky",
75
85
  "pretest": "npm run build",
86
+ "type-check": "tsc --noEmit",
76
87
  "test": "nyc mocha --forbid-only --loader=ts-node/esm",
77
88
  "exec-perms": "shx chmod +x dist/*.js",
78
89
  "test:watch": "nyc mocha --watch --forbid-only"
79
90
  }
80
- }
91
+ }