Skip to content

Upgrade @modelcontextprotocol/sdk package #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jul 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,6 @@ functional breakpoints in the code:
To set up local debugging with breakpoints:

1. Store your Heroku auth token in the VS Code user settings:

- Open the Command Palette (Cmd/Ctrl + Shift + P).
- Type `Preferences: Open User Settings (JSON)`.
- Add the following snippet:
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default defineConfig([
},
{
files: ['**/*.ts'],
ignores: ['**/dist', '**/*.spec.ts', '**/*.d.ts'],
ignores: ['**/dist', '**/*.spec.ts', '**/*.d.ts', '**/*.spechelper.ts'],
extends: compat.extends(
'eslint-config-salesforce-typescript',
'plugin:jsdoc/recommended-typescript-error',
Expand Down
5,279 changes: 2,733 additions & 2,546 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"type": "module",
"dependencies": {
"@heroku/plugin-ai": "^1.0.1",
"@modelcontextprotocol/sdk": "1.9.0",
"@modelcontextprotocol/sdk": "^1.16.0",
"cheerio": "^1.1.0",
"jsonschema": "^1.5.0",
"node-fetch": "^3.3.2",
Expand Down Expand Up @@ -85,6 +85,7 @@
"posttest": "npm run lint",
"prepare": "husky",
"pretest": "npm run build",
"type-check": "tsc --noEmit",
"test": "nyc mocha --forbid-only --loader=ts-node/esm",
"exec-perms": "shx chmod +x dist/*.js",
"test:watch": "nyc mocha --watch --forbid-only",
Expand Down
150 changes: 53 additions & 97 deletions src/tools/addons.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { expect } from 'chai';
import sinon from 'sinon';
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { HerokuREPL } from '../repl/heroku-cli-repl.js';
import {
listAddonsOptionsSchema,
getAddonInfoOptionsSchema,
Expand All @@ -16,32 +14,26 @@ import {
} from './addons.js';
import { CommandBuilder } from '../utils/command-builder.js';
import { TOOL_COMMAND_MAP } from '../utils/tool-commands.js';
import { setupMcpToolMocks } from '../utils/mcp-tool-mocks.spechelper.js';

describe('addons topic tools', () => {
describe('registerListAddonsTool', () => {
let server: sinon.SinonStubbedInstance<McpServer>;
let herokuRepl: sinon.SinonStubbedInstance<HerokuREPL>;
let mocks: ReturnType<typeof setupMcpToolMocks>;
let toolCallback: Function;

beforeEach(() => {
server = sinon.createStubInstance(McpServer);
herokuRepl = sinon.createStubInstance(HerokuREPL);

server.tool.callsFake((_name, _description, _schema, callback) => {
toolCallback = callback;
return server;
});

registerListAddonsTool(server, herokuRepl);
mocks = setupMcpToolMocks();
registerListAddonsTool(mocks.server, mocks.herokuRepl);
toolCallback = mocks.getToolCallback();
});

afterEach(() => {
sinon.restore();
});

it('registers the tool with correct name and schema', () => {
expect(server.tool.calledOnce).to.be.true;
const call = server.tool.getCall(0);
expect(mocks.server.tool.calledOnce).to.be.true;
const call = mocks.server.tool.getCall(0);
expect(call.args[0]).to.equal('list_addons');
expect(call.args[2]).to.deep.equal(listAddonsOptionsSchema.shape);
});
Expand All @@ -54,10 +46,10 @@ describe('addons topic tools', () => {
' test-app-2 redis-elliptical-12345 heroku-redis:mini ~$0.004/hour $3/month created \n';
const expectedCommand = new CommandBuilder(TOOL_COMMAND_MAP.LIST_ADDONS).addFlags({ all: true }).build();

herokuRepl.executeCommand.resolves(expectedOutput);
mocks.herokuRepl.executeCommand.resolves(expectedOutput);

const result = await toolCallback({ all: true }, {});
expect(herokuRepl.executeCommand.calledOnceWith(expectedCommand)).to.be.true;
expect(mocks.herokuRepl.executeCommand.calledOnceWith(expectedCommand)).to.be.true;
expect(result).to.deep.equal({
content: [{ type: 'text', text: expectedOutput }]
});
Expand All @@ -71,40 +63,33 @@ describe('addons topic tools', () => {
' └─ as REDIS_TEST_DB \n';
const expectedCommand = new CommandBuilder(TOOL_COMMAND_MAP.LIST_ADDONS).addFlags({ app: 'test-app-2' }).build();

herokuRepl.executeCommand.resolves(expectedOutput);
mocks.herokuRepl.executeCommand.resolves(expectedOutput);

const result = await toolCallback({ app: 'test-app-2' }, {});
expect(herokuRepl.executeCommand.calledOnceWith(expectedCommand)).to.be.true;
expect(mocks.herokuRepl.executeCommand.calledOnceWith(expectedCommand)).to.be.true;
expect(result).to.deep.equal({
content: [{ type: 'text', text: expectedOutput }]
});
});
});

describe('registerGetAddonInfoTool', () => {
let server: sinon.SinonStubbedInstance<McpServer>;
let herokuRepl: sinon.SinonStubbedInstance<HerokuREPL>;
let mocks: ReturnType<typeof setupMcpToolMocks>;
let toolCallback: Function;

beforeEach(() => {
server = sinon.createStubInstance(McpServer);
herokuRepl = sinon.createStubInstance(HerokuREPL);

server.tool.callsFake((_name, _description, _schema, callback) => {
toolCallback = callback;
return server;
});

registerGetAddonInfoTool(server, herokuRepl);
mocks = setupMcpToolMocks();
registerGetAddonInfoTool(mocks.server, mocks.herokuRepl);
toolCallback = mocks.getToolCallback();
});

afterEach(() => {
sinon.restore();
});

it('registers the tool with correct name and schema', () => {
expect(server.tool.calledOnce).to.be.true;
const call = server.tool.getCall(0);
expect(mocks.server.tool.calledOnce).to.be.true;
const call = mocks.server.tool.getCall(0);
expect(call.args[0]).to.equal('get_addon_info');
expect(call.args[2]).to.deep.equal(getAddonInfoOptionsSchema.shape);
});
Expand All @@ -119,10 +104,10 @@ describe('addons topic tools', () => {
.addPositionalArguments({ addon: 'postgresql-curved-12345' })
.build();

herokuRepl.executeCommand.resolves(expectedOutput);
mocks.herokuRepl.executeCommand.resolves(expectedOutput);

const result = await toolCallback({ addon: 'postgresql-curved-12345' }, {});
expect(herokuRepl.executeCommand.calledOnceWith(expectedCommand)).to.be.true;
expect(mocks.herokuRepl.executeCommand.calledOnceWith(expectedCommand)).to.be.true;
expect(result).to.deep.equal({
content: [{ type: 'text', text: expectedOutput }]
});
Expand All @@ -139,40 +124,33 @@ describe('addons topic tools', () => {
.addFlags({ app: 'test-app' })
.build();

herokuRepl.executeCommand.resolves(expectedOutput);
mocks.herokuRepl.executeCommand.resolves(expectedOutput);

const result = await toolCallback({ addon: 'DATABASE', app: 'test-app' }, {});
expect(herokuRepl.executeCommand.calledOnceWith(expectedCommand)).to.be.true;
expect(mocks.herokuRepl.executeCommand.calledOnceWith(expectedCommand)).to.be.true;
expect(result).to.deep.equal({
content: [{ type: 'text', text: expectedOutput }]
});
});
});

describe('registerCreateAddonTool', () => {
let server: sinon.SinonStubbedInstance<McpServer>;
let herokuRepl: sinon.SinonStubbedInstance<HerokuREPL>;
let mocks: ReturnType<typeof setupMcpToolMocks>;
let toolCallback: Function;

beforeEach(() => {
server = sinon.createStubInstance(McpServer);
herokuRepl = sinon.createStubInstance(HerokuREPL);

server.tool.callsFake((_name, _description, _schema, callback) => {
toolCallback = callback;
return server;
});

registerCreateAddonTool(server, herokuRepl);
mocks = setupMcpToolMocks();
registerCreateAddonTool(mocks.server, mocks.herokuRepl);
toolCallback = mocks.getToolCallback();
});

afterEach(() => {
sinon.restore();
});

it('registers the tool with correct name and schema', () => {
expect(server.tool.calledOnce).to.be.true;
const call = server.tool.getCall(0);
expect(mocks.server.tool.calledOnce).to.be.true;
const call = mocks.server.tool.getCall(0);
expect(call.args[0]).to.equal('create_addon');
expect(call.args[2]).to.deep.equal(createAddonOptionsSchema.shape);
});
Expand All @@ -191,7 +169,7 @@ describe('addons topic tools', () => {
.addPositionalArguments({ 'service:plan': 'heroku-postgresql:essential-0' })
.build();

herokuRepl.executeCommand.resolves(expectedOutput);
mocks.herokuRepl.executeCommand.resolves(expectedOutput);

const result = await toolCallback(
{
Expand All @@ -202,7 +180,7 @@ describe('addons topic tools', () => {
},
{}
);
expect(herokuRepl.executeCommand.calledOnceWith(expectedCommand)).to.be.true;
expect(mocks.herokuRepl.executeCommand.calledOnceWith(expectedCommand)).to.be.true;
expect(result).to.deep.equal({
content: [{ type: 'text', text: expectedOutput }]
});
Expand All @@ -218,7 +196,7 @@ describe('addons topic tools', () => {
.addPositionalArguments({ 'service:plan': 'heroku-postgresql:essential-0' })
.build();

herokuRepl.executeCommand.resolves(expectedOutput);
mocks.herokuRepl.executeCommand.resolves(expectedOutput);

const result = await toolCallback(
{
Expand All @@ -227,37 +205,30 @@ describe('addons topic tools', () => {
},
{}
);
expect(herokuRepl.executeCommand.calledOnceWith(expectedCommand)).to.be.true;
expect(mocks.herokuRepl.executeCommand.calledOnceWith(expectedCommand)).to.be.true;
expect(result).to.deep.equal({
content: [{ type: 'text', text: expectedOutput }]
});
});
});

describe('registerListAddonServicesTool', () => {
let server: sinon.SinonStubbedInstance<McpServer>;
let herokuRepl: sinon.SinonStubbedInstance<HerokuREPL>;
let mocks: ReturnType<typeof setupMcpToolMocks>;
let toolCallback: Function;

beforeEach(() => {
server = sinon.createStubInstance(McpServer);
herokuRepl = sinon.createStubInstance(HerokuREPL);

server.tool.callsFake((_name, _description, _schema, callback) => {
toolCallback = callback;
return server;
});

registerListAddonServicesTool(server, herokuRepl);
mocks = setupMcpToolMocks();
registerListAddonServicesTool(mocks.server, mocks.herokuRepl);
toolCallback = mocks.getToolCallback();
});

afterEach(() => {
sinon.restore();
});

it('registers the tool with correct name and schema', () => {
expect(server.tool.calledOnce).to.be.true;
const call = server.tool.getCall(0);
expect(mocks.server.tool.calledOnce).to.be.true;
const call = mocks.server.tool.getCall(0);
expect(call.args[0]).to.equal('list_addon_services');
expect(call.args[2]).to.deep.equal(listAddonServicesOptionsSchema.shape);
});
Expand All @@ -269,41 +240,33 @@ describe('addons topic tools', () => {
' heroku-postgresql Heroku PostgreSQL ga \n' +
' heroku-redis Heroku Key-Value Store ga \n';
const expectedCommand = new CommandBuilder(TOOL_COMMAND_MAP.LIST_ADDON_SERVICES).build();

herokuRepl.executeCommand.resolves(expectedOutput);
mocks.herokuRepl.executeCommand.resolves(expectedOutput);

const result = await toolCallback({}, {});
expect(herokuRepl.executeCommand.calledOnceWith(expectedCommand)).to.be.true;
expect(mocks.herokuRepl.executeCommand.calledOnceWith(expectedCommand)).to.be.true;
expect(result).to.deep.equal({
content: [{ type: 'text', text: expectedOutput }]
});
});
});

describe('registerListAddonPlansTool', () => {
let server: sinon.SinonStubbedInstance<McpServer>;
let herokuRepl: sinon.SinonStubbedInstance<HerokuREPL>;
let mocks: ReturnType<typeof setupMcpToolMocks>;
let toolCallback: Function;

beforeEach(() => {
server = sinon.createStubInstance(McpServer);
herokuRepl = sinon.createStubInstance(HerokuREPL);

server.tool.callsFake((_name, _description, _schema, callback) => {
toolCallback = callback;
return server;
});

registerListAddonPlansTool(server, herokuRepl);
mocks = setupMcpToolMocks();
registerListAddonPlansTool(mocks.server, mocks.herokuRepl);
toolCallback = mocks.getToolCallback();
});

afterEach(() => {
sinon.restore();
});

it('registers the tool with correct name and schema', () => {
expect(server.tool.calledOnce).to.be.true;
const call = server.tool.getCall(0);
expect(mocks.server.tool.calledOnce).to.be.true;
const call = mocks.server.tool.getCall(0);
expect(call.args[0]).to.equal('list_addon_plans');
expect(call.args[2]).to.deep.equal(listAddonPlansOptionsSchema.shape);
});
Expand All @@ -317,11 +280,10 @@ describe('addons topic tools', () => {
const expectedCommand = new CommandBuilder(TOOL_COMMAND_MAP.LIST_ADDON_PLANS)
.addPositionalArguments({ service: 'heroku-postgresql' })
.build();

herokuRepl.executeCommand.resolves(expectedOutput);
mocks.herokuRepl.executeCommand.resolves(expectedOutput);

const result = await toolCallback({ service: 'heroku-postgresql' }, {});
expect(herokuRepl.executeCommand.calledOnceWith(expectedCommand)).to.be.true;
expect(mocks.herokuRepl.executeCommand.calledOnceWith(expectedCommand)).to.be.true;
expect(result).to.deep.equal({
content: [{ type: 'text', text: expectedOutput }]
});
Expand All @@ -330,18 +292,10 @@ describe('addons topic tools', () => {

// Common error handling test for all tools
describe('error handling', () => {
let server: sinon.SinonStubbedInstance<McpServer>;
let herokuRepl: sinon.SinonStubbedInstance<HerokuREPL>;
let toolCallback: Function;
let mocks: ReturnType<typeof setupMcpToolMocks>;

beforeEach(() => {
server = sinon.createStubInstance(McpServer);
herokuRepl = sinon.createStubInstance(HerokuREPL);

server.tool.callsFake((_name, _description, _schema, callback) => {
toolCallback = callback;
return server;
});
mocks = setupMcpToolMocks();
});

afterEach(() => {
Expand All @@ -351,7 +305,7 @@ describe('addons topic tools', () => {
it('handles CLI errors properly for all tools', async () => {
const expectedOutput = '<<<BEGIN RESULTS>>>\n<<<ERROR>>>API error<<<END ERROR>>><<<END RESULTS>>>';

herokuRepl.executeCommand.resolves(expectedOutput);
mocks.herokuRepl.executeCommand.resolves(expectedOutput);

// Test error handling for each tool
const tools = [
Expand All @@ -366,8 +320,10 @@ describe('addons topic tools', () => {
];

for (const tool of tools) {
tool.register(server, herokuRepl);
tool.register(mocks.server, mocks.herokuRepl);
const toolCallback = mocks.getToolCallback();
const result = await toolCallback(tool.options, {});
console.log('result', result);
expect(result).to.deep.equal({
isError: true,
content: [
Expand Down
Loading