Skip to content
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
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"type": "module",
"dependencies": {
"@modelcontextprotocol/sdk": "^1.8.0",
"heroku": "10.4.1-alpha.3",
"heroku": "10.4.1-alpha.4",
"jsonschema": "^1.5.0",
"tar-stream": "^3.1.7",
"zod": "^3.24.2",
Expand Down
10 changes: 9 additions & 1 deletion src/repl/heroku-cli-repl.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { EventEmitter } from 'node:events';
import * as childProcess from 'node:child_process';
import { expect } from 'chai';
import sinon from 'sinon';
import { HerokuREPL } from './heroku-cli-repl.js';
import * as pjson from '../../package.json' with { type: 'json' };

const VERSION = pjson.default.version;

describe('HerokuREPL', () => {
let repl: HerokuREPL;
Expand Down Expand Up @@ -48,6 +50,12 @@ describe('HerokuREPL', () => {
it('should create a new process when initialized', () => {
expect(spawnStub.calledOnce).to.be.true;
expect(spawnStub.firstCall.args[2].env.HEROKU_MCP_MODE).to.equal('true');
expect(spawnStub.firstCall.args[2].env.HEROKU_MCP_SERVER_VERSION).to.equal(VERSION);
expect(spawnStub.firstCall.args[2].env.HEROKU_HEADERS).to.equal(
JSON.stringify({
'User-Agent': `Heroku-MCP-Server/${VERSION} (${process.platform}; ${process.arch}; node/${process.version})`
})
);
});
});

Expand Down
10 changes: 9 additions & 1 deletion src/repl/heroku-cli-repl.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { spawn, type ChildProcess } from 'node:child_process';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import * as pjson from '../../package.json' with { type: 'json' };

const heroku = path.parse(path.relative(process.cwd(), fileURLToPath(import.meta.resolve('heroku', import.meta.url))));
const herokuRunPath = path.join(heroku.dir, '../', 'bin/run');

type CommandQueueItem = { command: string; promise: Promise<string>; resolver: (value: string) => void };
const COMMAND_END_RESULTS_MESSAGE = '<<<END RESULTS>>>';
const READY_MESSAGE = 'heroku >';
const VERSION = pjson.default.version;

/**
* A class that manages a Heroku CLI REPL process
* and allows for durably executing commands via a queue.
Expand Down Expand Up @@ -41,6 +44,7 @@ export class HerokuREPL {
private pauseIteratorResolver: (() => void) | undefined;
private readonly commandTimeout: number;
private commandTimeoutId: NodeJS.Timeout | undefined;
private readonly userAgent: string = `Heroku-MCP-Server/${VERSION} (${process.platform}; ${process.arch}; node/${process.version})`;

/**
* Create a new HerokuREPL instance
Expand Down Expand Up @@ -139,7 +143,11 @@ export class HerokuREPL {
signal: this.abortController.signal,
env: {
...process.env,
HEROKU_MCP_MODE: 'true'
HEROKU_MCP_MODE: 'true',
HEROKU_MCP_SERVER_VERSION: VERSION,
HEROKU_HEADERS: JSON.stringify({
'User-Agent': this.userAgent
})
}
});

Expand Down