@heroku/mcp-server 1.0.7-alpha.1 → 1.0.7

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/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # heroku-mcp-server
2
2
 
3
+ [![Install MCP Server](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/install-mcp?name=heroku&config=eyJjb21tYW5kIjoibnB4IC15IEBoZXJva3UvbWNwLXNlcnZlciIsImVudiI6eyJIRVJPS1VfQVBJX0tFWSI6IjxZT1VSX0hFUk9LVV9BVVRIX1RPS0VOPiJ9fQ%3D%3D)
3
4
  [![smithery badge](https://smithery.ai/badge/@heroku/heroku-mcp-server)](https://smithery.ai/server/@heroku/heroku-mcp-server)
4
5
 
5
6
  > The Heroku Platform MCP Server works on Common Runtime, Cedar Private and Shield Spaces, and Fir Private Spaces.
@@ -29,10 +30,129 @@ Note: The Heroku Platform MCP Server is currently in early development. As we co
29
30
  implementation, the available functionality and tools may evolve. We welcome feedback and contributions to help shape
30
31
  the future of this project.
31
32
 
32
- > **Note:** The Heroku Platform MCP Server requires the Heroku CLI to be installed globally (v10.8.1+). Ensure you have
33
- > the correct version by running `heroku --version`.
33
+ > **Note:** The [Heroku Platform MCP Server](https://devcenter.heroku.com/articles/heroku-mcp-server) requires the
34
+ > Heroku CLI to be installed globally (v10.8.1+). Ensure you have the correct version by running `heroku --version`.
34
35
 
35
- ## Authentication
36
+ ## Configure the Heroku Platform MCP Server
37
+
38
+ You can configure Claude Desktop, Zed, Cursor, Windsurf, and other clients to work with the Heroku Platform MCP Server.
39
+
40
+ ### Configure the Heroku Platform MCP Server with `heroku mcp:start`
41
+
42
+ Use `heroku mcp:start` to launch the Heroku Platform MCP Server. We recommend this method as it leverages your existing
43
+ Heroku CLI authentication, so you don't need to set the
44
+ [`HEROKU_API_KEY`](https://devcenter.heroku.com/articles/heroku-mcp-server#authentication) environment variable. The
45
+ `heroku mcp:start` command is available in Heroku CLI version 10.8.1 and later.
46
+
47
+ There are several benefits to configuring with `heroku mcp:start`:
48
+
49
+ - No need to manage or expose your Heroku API key
50
+ - Uses your current Heroku CLI authentication context
51
+ - Works seamlessly with supported clients
52
+
53
+ #### Example configuration for [Claude Desktop](https://claude.ai/download):
54
+
55
+ ```json
56
+ {
57
+ "mcpServers": {
58
+ "heroku": {
59
+ "command": "heroku mcp:start"
60
+ }
61
+ }
62
+ }
63
+ ```
64
+
65
+ #### Example configuration for [Zed](https://github.com/zed-industries/zed):
66
+
67
+ ```json
68
+ {
69
+ "context_servers": {
70
+ "heroku": {
71
+ "command": {
72
+ "path": "heroku",
73
+ "args": ["mcp:start"]
74
+ }
75
+ }
76
+ }
77
+ }
78
+ ```
79
+
80
+ #### Example configuration for [Cursor](https://www.cursor.com/):
81
+
82
+ ```json
83
+ {
84
+ "mcpServers": {
85
+ "heroku": {
86
+ "command": "heroku mcp:start"
87
+ }
88
+ }
89
+ }
90
+ ```
91
+
92
+ #### Example configuration for [Windsurf](https://www.windsurf.com/):
93
+
94
+ ```json
95
+ {
96
+ "mcpServers": {
97
+ "heroku": {
98
+ "command": "heroku mcp:start"
99
+ }
100
+ }
101
+ }
102
+ ```
103
+
104
+ #### Example configuration for [Cline](https://cline.bot):
105
+
106
+ ```json
107
+ {
108
+ "mcpServers": {
109
+ "heroku": {
110
+ "command": "heroku mcp:start"
111
+ }
112
+ }
113
+ }
114
+ ```
115
+
116
+ #### Example configuration for [VSCode](https://code.visualstudio.com/):
117
+
118
+ ```json
119
+ {
120
+ "mcp": {
121
+ "servers": {
122
+ "heroku": {
123
+ "type": "stdio",
124
+ "command": "heroku",
125
+ "args": ["mcp:start"]
126
+ }
127
+ }
128
+ }
129
+ }
130
+ ```
131
+
132
+ #### Example configuration for [Trae](https://trae.ai):
133
+
134
+ ```json
135
+ {
136
+ "mcpServers": {
137
+ "heroku": {
138
+ "command": "heroku mcp:start"
139
+ }
140
+ }
141
+ }
142
+ ```
143
+
144
+ > **Note:** When you use `heroku mcp:start`, the server authenticates using your current Heroku CLI session so you don't
145
+ > need to set the `HEROKU_API_KEY` environment variable. We recommend you use `heroku mcp:start`, but if you prefer to
146
+ > use an API key, you can use the alternate configuration below.
147
+
148
+ ### Configure the Heroku Platform MCP Server with `npx -y @heroku/mcp-server`
149
+
150
+ You can also launch the Heroku Platform MCP Server using the `npx -y @heroku/mcp-server` command. This method requires
151
+ you to set the [`HEROKU_API_KEY`](https://devcenter.heroku.com/articles/heroku-mcp-server#authentication) environment
152
+ variable with your Heroku
153
+ [authorization token](https://devcenter.heroku.com/articles/authentication#retrieving-the-api-token).
154
+
155
+ #### Generating the `HEROKU_API_KEY`
36
156
 
37
157
  Generate a Heroku authorization token with one of these methods:
38
158
 
@@ -55,13 +175,7 @@ Generate a Heroku authorization token with one of these methods:
55
175
  2. Open the Applications tab.
56
176
  3. Next to **Authorizations**, click **Create authorization**.
57
177
 
58
- ## Configure the Heroku Platform MCP Server
59
-
60
- You can configure Claude Desktop, Zed, Cursor, Windsurf and others to work with the Heroku Platform MCP Server.
61
-
62
- ### [Claude Desktop](https://claude.ai/download)
63
-
64
- Add this snippet to your `claude_desktop_config.json`:
178
+ #### Example configuration for [Claude Desktop](https://claude.ai/download):
65
179
 
66
180
  ```json
67
181
  {
@@ -77,9 +191,7 @@ Add this snippet to your `claude_desktop_config.json`:
77
191
  }
78
192
  ```
79
193
 
80
- ### [Zed](https://github.com/zed-industries/zed)
81
-
82
- Add this snippet to your Zed `settings.json`:
194
+ #### Example configuration for [Zed](https://github.com/zed-industries/zed):
83
195
 
84
196
  ```json
85
197
  {
@@ -97,14 +209,7 @@ Add this snippet to your Zed `settings.json`:
97
209
  }
98
210
  ```
99
211
 
100
- ### [Cursor](https://www.cursor.com/)
101
-
102
- > **Note:** Both the simple and explicit forms work, but the key should be `"heroku"` (not `"heroku-mcp-server"`) for
103
- > maximum compatibility with agent tools.
104
-
105
- Add this snippet to your Cursor `mcp.json`:
106
-
107
- **Simple form:**
212
+ #### Example configuration for [Cursor](https://www.cursor.com/):
108
213
 
109
214
  ```json
110
215
  {
@@ -119,25 +224,7 @@ Add this snippet to your Cursor `mcp.json`:
119
224
  }
120
225
  ```
121
226
 
122
- **Explicit form:**
123
-
124
- ```json
125
- {
126
- "mcpServers": {
127
- "heroku": {
128
- "command": "npx",
129
- "args": ["-y", "@heroku/mcp-server"],
130
- "env": {
131
- "HEROKU_API_KEY": "<YOUR_HEROKU_AUTH_TOKEN>"
132
- }
133
- }
134
- }
135
- }
136
- ```
137
-
138
- ### [Windsurf](https://www.windsurf.com/)
139
-
140
- Add this snippet to your Windsurf `mcp_config.json`:
227
+ #### Example configuration for [Windsurf](https://www.windsurf.com/):
141
228
 
142
229
  ```json
143
230
  {
@@ -153,9 +240,7 @@ Add this snippet to your Windsurf `mcp_config.json`:
153
240
  }
154
241
  ```
155
242
 
156
- ### [Cline](https://cline.bot)
157
-
158
- Add this snippet to your Cline `config.json`:
243
+ #### Example configuration for [Cline](https://cline.bot):
159
244
 
160
245
  ```json
161
246
  {
@@ -171,9 +256,7 @@ Add this snippet to your Cline `config.json`:
171
256
  }
172
257
  ```
173
258
 
174
- ### [VSCode](https://code.visualstudio.com/)
175
-
176
- Add this snippet to your VSCode `settings.json` or `.vscode/mcp.json`:
259
+ #### Example configuration for [VSCode](https://code.visualstudio.com/):
177
260
 
178
261
  ```json
179
262
  {
@@ -192,9 +275,7 @@ Add this snippet to your VSCode `settings.json` or `.vscode/mcp.json`:
192
275
  }
193
276
  ```
194
277
 
195
- ### [Trae](https://trae.ai)
196
-
197
- Add this snippet to your Trae `mcp_settings.json`:
278
+ #### Example configuration for [Trae](https://trae.ai):
198
279
 
199
280
  ```json
200
281
  {
@@ -210,6 +291,9 @@ Add this snippet to your Trae `mcp_settings.json`:
210
291
  }
211
292
  ```
212
293
 
294
+ > **Note:** When you use `npx -y @heroku/mcp-server`, you must set the `HEROKU_API_KEY` environment variable with your
295
+ > Heroku authorization token.
296
+
213
297
  ## Available Tools
214
298
 
215
299
  ### Application Management
@@ -308,7 +392,6 @@ functional breakpoints in the code:
308
392
  To set up local debugging with breakpoints:
309
393
 
310
394
  1. Store your Heroku auth token in the VS Code user settings:
311
-
312
395
  - Open the Command Palette (Cmd/Ctrl + Shift + P).
313
396
  - Type `Preferences: Open User Settings (JSON)`.
314
397
  - Add the following snippet:
File without changes
package/dist/index.js CHANGED
@@ -13,9 +13,21 @@ import * as pipelines from './tools/pipelines.js';
13
13
  import * as deployToHeroku from './tools/deploy-to-heroku.js';
14
14
  import * as logs from './tools/logs.js';
15
15
  import * as ai from './tools/ai.js';
16
+ import * as devCenterResource from './resources/dev-center-resource.js';
16
17
  import { HerokuREPL } from './repl/heroku-cli-repl.js';
17
18
  const VERSION = pjson.default.version;
18
- const server = new McpServer({ name: 'Heroku MCP Server', version: VERSION });
19
+ const server = new McpServer({ name: 'Heroku MCP Server', version: VERSION }, {
20
+ capabilities: {
21
+ tools: {
22
+ list: {
23
+ description: 'List all tools',
24
+ parameters: {
25
+ type: 'object'
26
+ }
27
+ }
28
+ }
29
+ }
30
+ });
19
31
  const requestTimeout = isNaN(Number(process.env.MCP_SERVER_REQUEST_TIMEOUT))
20
32
  ? 15_000
21
33
  : Number(process.env.MCP_SERVER_REQUEST_TIMEOUT);
@@ -30,7 +42,6 @@ apps.registerListAppsTool(server, herokuRepl);
30
42
  apps.registerGetAppInfoTool(server, herokuRepl);
31
43
  apps.registerCreateAppTool(server, herokuRepl);
32
44
  apps.registerRenameAppTool(server, herokuRepl);
33
- apps.registerTransferAppTool(server, herokuRepl);
34
45
  // Maintenance mode tools
35
46
  maintenance.registerMaintenanceOnTool(server, herokuRepl);
36
47
  maintenance.registerMaintenanceOffTool(server, herokuRepl);
@@ -73,6 +84,8 @@ deployToHeroku.registerDeployOneOffDynoTool(server);
73
84
  ai.registerListAiAvailableModelsTool(server, herokuRepl);
74
85
  ai.registerProvisionAiModelTool(server, herokuRepl);
75
86
  ai.registerMakeAiInferenceTool(server, herokuRepl);
87
+ // Register the Dev Center resource
88
+ devCenterResource.registerDevCenterResource(server);
76
89
  /**
77
90
  * Run the server
78
91
  */
@@ -1,4 +1,4 @@
1
- import { spawn } from 'node:child_process';
1
+ import { spawn, spawnSync } from 'node:child_process';
2
2
  import { EventEmitter } from 'node:events';
3
3
  import * as pjson from '../../package.json' with { type: 'json' };
4
4
  import { handleCliOutput } from '../utils/handle-cli-output.js';
@@ -27,6 +27,7 @@ const VERSION = pjson.default.version;
27
27
  */
28
28
  export class HerokuREPL extends EventEmitter {
29
29
  static spawn = spawn;
30
+ static spawnSync = spawnSync;
30
31
  isProcessingCommand = false;
31
32
  isReady = false;
32
33
  process;
@@ -96,6 +97,42 @@ export class HerokuREPL extends EventEmitter {
96
97
  this.pauseIteratorResolver?.();
97
98
  return commandPromise;
98
99
  }
100
+ /**
101
+ * Determines the appropriate CLI command and arguments to use for spawning the Heroku REPL process.
102
+ * Checks for npx first, then falls back to heroku CLI >= 10.10.0 if available.
103
+ * Emits a fatalError and returns null if neither is available.
104
+ *
105
+ * @returns An object with cliCommand and cliArgs, or null if neither CLI is available.
106
+ */
107
+ getHerokuCliCommandAndArgs() {
108
+ // Check for npx presence
109
+ const npxCheck = HerokuREPL.spawnSync('npx', ['--version'], { encoding: 'utf-8' });
110
+ if (!npxCheck.error && npxCheck.status === 0) {
111
+ return { cliCommand: 'npx', cliArgs: ['-y', 'heroku@latest', '--repl'] };
112
+ }
113
+ else {
114
+ // Fallback: check for heroku CLI and version
115
+ const herokuCheck = HerokuREPL.spawnSync('heroku', ['version'], { encoding: 'utf-8' });
116
+ if (!herokuCheck.error &&
117
+ herokuCheck.status === 0 &&
118
+ typeof herokuCheck.stdout === 'string' &&
119
+ /heroku\/(\d+\.\d+\.\d+)/.test(herokuCheck.stdout)) {
120
+ const versionMatch = herokuCheck.stdout.match(/heroku\/(\d+\.\d+\.\d+)/);
121
+ if (versionMatch) {
122
+ const [major, minor] = versionMatch[1].split('.').map(Number);
123
+ if (major > 10 || (major === 10 && minor >= 10)) {
124
+ return { cliCommand: 'heroku', cliArgs: ['--repl'] };
125
+ }
126
+ else {
127
+ this.emit('fatalError', handleCliOutput(`Startup error: Heroku CLI version 10.10.0 or higher is required for this MCP server. Detected version: ${versionMatch[1]}`));
128
+ return null;
129
+ }
130
+ }
131
+ }
132
+ this.emit('fatalError', handleCliOutput('Startup error: npx is not installed and Heroku CLI (10.10.0+) is not available in your PATH. Please install one of them.'));
133
+ return null;
134
+ }
135
+ }
99
136
  /**
100
137
  * Initializes the Heroku CLI process in REPL mode and sets up
101
138
  * event listeners for stdout and stderr.
@@ -110,13 +147,18 @@ export class HerokuREPL extends EventEmitter {
110
147
  if (this.abortController.signal.aborted) {
111
148
  return;
112
149
  }
150
+ const cliInfo = this.getHerokuCliCommandAndArgs();
151
+ if (!cliInfo) {
152
+ return;
153
+ }
154
+ const { cliCommand, cliArgs } = cliInfo;
113
155
  if (this.process) {
114
156
  this.process.removeAllListeners();
115
157
  this.process.kill();
116
158
  this.process = undefined;
117
159
  }
118
160
  try {
119
- this.process = HerokuREPL.spawn('heroku', ['--repl'], {
161
+ this.process = HerokuREPL.spawn(cliCommand, cliArgs, {
120
162
  stdio: ['pipe', 'pipe', 'pipe'],
121
163
  signal: this.abortController.signal,
122
164
  env: {
@@ -142,4 +142,165 @@ describe('HerokuREPL', () => {
142
142
  expect(mcpError.content[0].text).to.include('Your Heroku CLI version does not support --repl mode');
143
143
  });
144
144
  });
145
+ describe('getHerokuCliCommandAndArgs', () => {
146
+ let spawnSyncStub;
147
+ let fatalSpy;
148
+ beforeEach(() => {
149
+ spawnSyncStub = sinon.stub(HerokuREPL, 'spawnSync');
150
+ fatalSpy = sinon.spy();
151
+ repl.on('fatalError', fatalSpy);
152
+ });
153
+ afterEach(() => {
154
+ spawnSyncStub.restore();
155
+ });
156
+ it('should return npx command when npx is available', () => {
157
+ spawnSyncStub.withArgs('npx', ['--version'], { encoding: 'utf-8' }).returns({
158
+ error: null,
159
+ status: 0,
160
+ stdout: '9.8.1'
161
+ });
162
+ const result = repl['getHerokuCliCommandAndArgs']();
163
+ expect(result).to.deep.equal({
164
+ cliCommand: 'npx',
165
+ cliArgs: ['-y', 'heroku@latest', '--repl']
166
+ });
167
+ expect(fatalSpy.called).to.be.false;
168
+ });
169
+ it('should return heroku command when npx is not available but heroku CLI >= 10.10.0 is available', () => {
170
+ // npx not available
171
+ spawnSyncStub.withArgs('npx', ['--version'], { encoding: 'utf-8' }).returns({
172
+ error: new Error('npx not found'),
173
+ status: 1,
174
+ stdout: ''
175
+ });
176
+ // heroku CLI available with version >= 10.10.0
177
+ spawnSyncStub.withArgs('heroku', ['version'], { encoding: 'utf-8' }).returns({
178
+ error: null,
179
+ status: 0,
180
+ stdout: 'heroku/10.15.0 (darwin-x64) node-v18.17.0'
181
+ });
182
+ const result = repl['getHerokuCliCommandAndArgs']();
183
+ expect(result).to.deep.equal({
184
+ cliCommand: 'heroku',
185
+ cliArgs: ['--repl']
186
+ });
187
+ expect(fatalSpy.called).to.be.false;
188
+ });
189
+ it('should return heroku command when npx is not available but heroku CLI > 10.x is available', () => {
190
+ // npx not available
191
+ spawnSyncStub.withArgs('npx', ['--version'], { encoding: 'utf-8' }).returns({
192
+ error: new Error('npx not found'),
193
+ status: 1,
194
+ stdout: ''
195
+ });
196
+ // heroku CLI available with version > 10.x
197
+ spawnSyncStub.withArgs('heroku', ['version'], { encoding: 'utf-8' }).returns({
198
+ error: null,
199
+ status: 0,
200
+ stdout: 'heroku/11.0.0 (darwin-x64) node-v18.17.0'
201
+ });
202
+ const result = repl['getHerokuCliCommandAndArgs']();
203
+ expect(result).to.deep.equal({
204
+ cliCommand: 'heroku',
205
+ cliArgs: ['--repl']
206
+ });
207
+ expect(fatalSpy.called).to.be.false;
208
+ });
209
+ it('should emit fatalError and return null when npx is not available and heroku CLI < 10.10.0 is available', () => {
210
+ // npx not available
211
+ spawnSyncStub.withArgs('npx', ['--version'], { encoding: 'utf-8' }).returns({
212
+ error: new Error('npx not found'),
213
+ status: 1,
214
+ stdout: ''
215
+ });
216
+ // heroku CLI available but version < 10.10.0
217
+ spawnSyncStub.withArgs('heroku', ['version'], { encoding: 'utf-8' }).returns({
218
+ error: null,
219
+ status: 0,
220
+ stdout: 'heroku/10.9.0 (darwin-x64) node-v18.17.0'
221
+ });
222
+ const result = repl['getHerokuCliCommandAndArgs']();
223
+ expect(result).to.be.null;
224
+ expect(fatalSpy.called).to.be.true;
225
+ const mcpError = fatalSpy.firstCall.args[0];
226
+ expect(mcpError.content[0].text).to.include('Startup error: Heroku CLI version 10.10.0 or higher is required');
227
+ expect(mcpError.content[0].text).to.include('Detected version: 10.9.0');
228
+ });
229
+ it('should emit fatalError and return null when npx is not available and heroku CLI is not available', () => {
230
+ // npx not available
231
+ spawnSyncStub.withArgs('npx', ['--version'], { encoding: 'utf-8' }).returns({
232
+ error: new Error('npx not found'),
233
+ status: 1,
234
+ stdout: ''
235
+ });
236
+ // heroku CLI not available
237
+ spawnSyncStub.withArgs('heroku', ['version'], { encoding: 'utf-8' }).returns({
238
+ error: new Error('heroku not found'),
239
+ status: 1,
240
+ stdout: ''
241
+ });
242
+ const result = repl['getHerokuCliCommandAndArgs']();
243
+ expect(result).to.be.null;
244
+ expect(fatalSpy.called).to.be.true;
245
+ const mcpError = fatalSpy.firstCall.args[0];
246
+ expect(mcpError.content[0].text).to.include('Startup error: npx is not installed and Heroku CLI (10.10.0+) is not available');
247
+ });
248
+ it('should emit fatalError and return null when npx is not available and heroku CLI version format is unexpected', () => {
249
+ // npx not available
250
+ spawnSyncStub.withArgs('npx', ['--version'], { encoding: 'utf-8' }).returns({
251
+ error: new Error('npx not found'),
252
+ status: 1,
253
+ stdout: ''
254
+ });
255
+ // heroku CLI available but version format is unexpected
256
+ spawnSyncStub.withArgs('heroku', ['version'], { encoding: 'utf-8' }).returns({
257
+ error: null,
258
+ status: 0,
259
+ stdout: 'some unexpected output without version'
260
+ });
261
+ const result = repl['getHerokuCliCommandAndArgs']();
262
+ expect(result).to.be.null;
263
+ expect(fatalSpy.called).to.be.true;
264
+ const mcpError = fatalSpy.firstCall.args[0];
265
+ expect(mcpError.content[0].text).to.include('Startup error: npx is not installed and Heroku CLI (10.10.0+) is not available');
266
+ });
267
+ it('should emit fatalError and return null when npx is not available and heroku CLI returns error', () => {
268
+ // npx not available
269
+ spawnSyncStub.withArgs('npx', ['--version'], { encoding: 'utf-8' }).returns({
270
+ error: new Error('npx not found'),
271
+ status: 1,
272
+ stdout: ''
273
+ });
274
+ // heroku CLI returns error
275
+ spawnSyncStub.withArgs('heroku', ['version'], { encoding: 'utf-8' }).returns({
276
+ error: new Error('heroku command failed'),
277
+ status: 1,
278
+ stdout: ''
279
+ });
280
+ const result = repl['getHerokuCliCommandAndArgs']();
281
+ expect(result).to.be.null;
282
+ expect(fatalSpy.called).to.be.true;
283
+ const mcpError = fatalSpy.firstCall.args[0];
284
+ expect(mcpError.content[0].text).to.include('Startup error: npx is not installed and Heroku CLI (10.10.0+) is not available');
285
+ });
286
+ it('should emit fatalError and return null when npx is not available and heroku CLI stdout is not a string', () => {
287
+ // npx not available
288
+ spawnSyncStub.withArgs('npx', ['--version'], { encoding: 'utf-8' }).returns({
289
+ error: new Error('npx not found'),
290
+ status: 1,
291
+ stdout: ''
292
+ });
293
+ // heroku CLI available but stdout is not a string
294
+ spawnSyncStub.withArgs('heroku', ['version'], { encoding: 'utf-8' }).returns({
295
+ error: null,
296
+ status: 0,
297
+ stdout: Buffer.from('heroku/10.15.0')
298
+ });
299
+ const result = repl['getHerokuCliCommandAndArgs']();
300
+ expect(result).to.be.null;
301
+ expect(fatalSpy.called).to.be.true;
302
+ const mcpError = fatalSpy.firstCall.args[0];
303
+ expect(mcpError.content[0].text).to.include('Startup error: npx is not installed and Heroku CLI (10.10.0+) is not available');
304
+ });
305
+ });
145
306
  });
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Registers the Heroku Dev Center resource with the MCP server.
3
+ * Exposes the /tmp/llms.txt file as a text resource, handling missing file gracefully.
4
+ *
5
+ * @param server - The MCP server instance
6
+ */
7
+ export function registerDevCenterResource(server) {
8
+ const DEV_CENTER_RESOURCE_URI = 'https://devcenter.heroku.com/llms.txt';
9
+ server.resource('heroku_dev_center', DEV_CENTER_RESOURCE_URI, {
10
+ mimeType: 'text/plain',
11
+ description: 'This resource provides a summary of Heroku Dev Center articles, and how to use Heroku.'
12
+ }, async () => {
13
+ let docText = '';
14
+ try {
15
+ const res = await fetch(DEV_CENTER_RESOURCE_URI);
16
+ docText = await res.text();
17
+ }
18
+ catch (err) {
19
+ docText = `[Error reading Dev Center data: ${err?.message || String(err)}]`;
20
+ }
21
+ if (!docText) {
22
+ docText = '[No Dev Center data available.]';
23
+ }
24
+ return {
25
+ contents: [
26
+ {
27
+ uri: DEV_CENTER_RESOURCE_URI,
28
+ mimeType: 'text/plain',
29
+ text: docText
30
+ }
31
+ ]
32
+ };
33
+ });
34
+ }
@@ -0,0 +1,19 @@
1
+ import { expect } from 'chai';
2
+ import sinon from 'sinon';
3
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
4
+ import { registerDevCenterResource } from './dev-center-resource.js';
5
+ describe('registerDevCenterResource', () => {
6
+ let server;
7
+ beforeEach(() => {
8
+ server = sinon.createStubInstance(McpServer);
9
+ });
10
+ afterEach(() => {
11
+ sinon.restore();
12
+ });
13
+ it('registers the resource with the correct name', () => {
14
+ registerDevCenterResource(server);
15
+ expect(server.resource.calledOnce).to.be.true;
16
+ const call = server.resource.getCall(0);
17
+ expect(call.args[0]).to.equal('heroku_dev_center');
18
+ });
19
+ });