chord-mcp 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/README.md +21 -0
- package/dist/api.js +44 -0
- package/dist/index.js +4 -0
- package/dist/server.js +38 -0
- package/package.json +48 -0
- package/server.json +20 -0
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Chord MCP
|
|
2
|
+
|
|
3
|
+
Build chords and scales from note names locally using music theory. No network, no key.
|
|
4
|
+
|
|
5
|
+
This file is self contained. It reads public data only and never writes to the machine. All output is bounded and honest about what could not be fetched.
|
|
6
|
+
|
|
7
|
+
## Tools
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
* `chord_notes` Notes of a chord.
|
|
11
|
+
* `scale_notes` Notes of a scale.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install
|
|
17
|
+
npm run build
|
|
18
|
+
node dist/index.js
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
All music theory runs locally.
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export class ChordError extends Error {
|
|
2
|
+
}
|
|
3
|
+
const NOTES = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"];
|
|
4
|
+
const ALIAS = { Db: "C#", Eb: "D#", Gb: "F#", Ab: "G#", Bb: "A#", "Cb": "B", "F#": "F#", "E#": "F" };
|
|
5
|
+
const CHORDS = {
|
|
6
|
+
maj: [0, 4, 7], min: [0, 3, 7], "7": [0, 4, 7, 10], maj7: [0, 4, 7, 11], min7: [0, 3, 7, 10],
|
|
7
|
+
dim: [0, 3, 6], aug: [0, 4, 8], sus2: [0, 2, 7], sus4: [0, 5, 7], "6": [0, 4, 7, 9], min6: [0, 3, 7, 9],
|
|
8
|
+
};
|
|
9
|
+
const SCALES = {
|
|
10
|
+
major: [0, 2, 4, 5, 7, 9, 11], minor: [0, 2, 3, 5, 7, 8, 10], dorian: [0, 2, 3, 5, 7, 9, 10],
|
|
11
|
+
phrygian: [0, 1, 3, 5, 7, 8, 10], lydian: [0, 2, 4, 6, 7, 9, 11], mixolydian: [0, 2, 4, 5, 7, 9, 10],
|
|
12
|
+
locrian: [0, 1, 3, 5, 6, 8, 10], harmonic_minor: [0, 2, 3, 5, 7, 8, 11], pentatonic: [0, 2, 4, 7, 9],
|
|
13
|
+
};
|
|
14
|
+
function rootIndex(root) {
|
|
15
|
+
const r = ALIAS[root] ?? root;
|
|
16
|
+
const i = NOTES.indexOf(r);
|
|
17
|
+
if (i < 0)
|
|
18
|
+
throw new ChordError(`Unknown root note ${root}`);
|
|
19
|
+
return i;
|
|
20
|
+
}
|
|
21
|
+
export async function chordNotes(args) {
|
|
22
|
+
const root = (args.root ?? "").trim();
|
|
23
|
+
if (!root)
|
|
24
|
+
throw new ChordError("Provide a root note like C or F#");
|
|
25
|
+
const type = (args.chord ?? "maj").toLowerCase();
|
|
26
|
+
const intervals = CHORDS[type];
|
|
27
|
+
if (!intervals)
|
|
28
|
+
throw new ChordError(`Unknown chord type ${type}. Use ${Object.keys(CHORDS).join(", ")}`);
|
|
29
|
+
const r = rootIndex(root);
|
|
30
|
+
const notes = intervals.map((iv) => NOTES[(r + iv) % 12]);
|
|
31
|
+
return `${root}${type === "maj" ? "" : type}: ${notes.join(" - ")}`;
|
|
32
|
+
}
|
|
33
|
+
export async function scaleNotes(args) {
|
|
34
|
+
const root = (args.root ?? "").trim();
|
|
35
|
+
if (!root)
|
|
36
|
+
throw new ChordError("Provide a root note");
|
|
37
|
+
const scale = (args.scale ?? "major").toLowerCase();
|
|
38
|
+
const intervals = SCALES[scale];
|
|
39
|
+
if (!intervals)
|
|
40
|
+
throw new ChordError(`Unknown scale ${scale}. Use ${Object.keys(SCALES).join(", ")}`);
|
|
41
|
+
const r = rootIndex(root);
|
|
42
|
+
const notes = intervals.map((iv) => NOTES[(r + iv) % 12]);
|
|
43
|
+
return `${root} ${scale}: ${notes.join(" - ")}`;
|
|
44
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
2
|
+
import { createServer } from "./server.js";
|
|
3
|
+
const main = async () => { const server = createServer(); await server.connect(new StdioServerTransport()); };
|
|
4
|
+
main().catch((error) => { console.error("Fatal error:", error); process.exit(1); });
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { chordNotes } from "./api.js";
|
|
4
|
+
import { scaleNotes } from "./api.js";
|
|
5
|
+
const text = (value) => ({ content: [{ type: "text", text: value }] });
|
|
6
|
+
const textError = (t) => ({ content: [{ type: "text", text: t }], isError: true });
|
|
7
|
+
const READ_ONLY = { readOnlyHint: true, openWorldHint: true };
|
|
8
|
+
const error = (e) => `Error: ${e instanceof Error ? e.message : String(e)}`;
|
|
9
|
+
export function createServer() {
|
|
10
|
+
const server = new McpServer({ name: "chord-mcp", version: "1.0.0" });
|
|
11
|
+
server.registerTool("chord_notes", {
|
|
12
|
+
title: "Chord notes",
|
|
13
|
+
description: "Get the notes of a chord.",
|
|
14
|
+
inputSchema: z.object({ root: z.string().describe("Root note like C or F#."), chord: z.string().describe("Chord type like maj, min, 7.").optional() }),
|
|
15
|
+
annotations: READ_ONLY,
|
|
16
|
+
}, async (args) => {
|
|
17
|
+
try {
|
|
18
|
+
return text(await chordNotes(args));
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
return textError(error(e));
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
server.registerTool("scale_notes", {
|
|
25
|
+
title: "Scale notes",
|
|
26
|
+
description: "Get the notes of a scale.",
|
|
27
|
+
inputSchema: z.object({ root: z.string().describe("Root note."), scale: z.string().describe("Scale like major or minor.").optional() }),
|
|
28
|
+
annotations: READ_ONLY,
|
|
29
|
+
}, async (args) => {
|
|
30
|
+
try {
|
|
31
|
+
return text(await scaleNotes(args));
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
return textError(error(e));
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return server;
|
|
38
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0.0",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/mrfentmen/chord-mcp.git"
|
|
7
|
+
},
|
|
8
|
+
"bin": {
|
|
9
|
+
"chord-mcp": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"server.json",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc -p tsconfig.json",
|
|
19
|
+
"start": "node dist/index.js",
|
|
20
|
+
"dev": "npm run build && node dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@modelcontextprotocol/sdk": "^1.0.4",
|
|
25
|
+
"zod": "^3.23.8",
|
|
26
|
+
"js-yaml": "^4.1.0",
|
|
27
|
+
"marked": "^14.0.0",
|
|
28
|
+
"turndown": "^7.2.0",
|
|
29
|
+
"diff": "^7.0.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/node": "^22.0.0",
|
|
33
|
+
"typescript": "^5.6.0"
|
|
34
|
+
},
|
|
35
|
+
"name": "chord-mcp",
|
|
36
|
+
"description": "Build chords and scales from note names locally. No network and no key.",
|
|
37
|
+
"mcpName": "io.github.mrfentmen/chord-mcp",
|
|
38
|
+
"keywords": [
|
|
39
|
+
"mcp",
|
|
40
|
+
"chord",
|
|
41
|
+
"music",
|
|
42
|
+
"scale",
|
|
43
|
+
"theory"
|
|
44
|
+
],
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=20"
|
|
47
|
+
}
|
|
48
|
+
}
|
package/server.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "io.github.mrfentmen/chord-mcp",
|
|
4
|
+
"description": "Build chords and scales from note names locally. No network and no key.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"url": "https://github.com/mrfentmen/chord-mcp",
|
|
7
|
+
"source": "github"
|
|
8
|
+
},
|
|
9
|
+
"version": "1.0.0",
|
|
10
|
+
"packages": [
|
|
11
|
+
{
|
|
12
|
+
"registryType": "npm",
|
|
13
|
+
"identifier": "chord-mcp",
|
|
14
|
+
"version": "1.0.0",
|
|
15
|
+
"transport": {
|
|
16
|
+
"type": "stdio"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|