mcp-udacity-commit 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 ADDED
@@ -0,0 +1,65 @@
1
+ # mcp-udacity-commit
2
+
3
+ An [MCP](https://modelcontextprotocol.io) server that validates and formats git
4
+ commit messages according to the
5
+ [Udacity Git Commit Message Style Guide](https://udacity.github.io/git-styleguide/).
6
+
7
+ ## What it exposes
8
+
9
+ | Primitive | Name | Purpose |
10
+ | --- | --- | --- |
11
+ | Resource | `udacity://commit-styleguide` | The style-guide rules, as markdown |
12
+ | Tool | `validate_commit_message` | Checks a message against every rule (type, ≤50-char subject, capitalization, no trailing period, blank line, ≤72-char body wrap) |
13
+ | Tool | `format_commit_message` | Builds a compliant message from `type` + `subject` + optional `body`/`footer` |
14
+
15
+ ## Install (published package)
16
+
17
+ ```bash
18
+ claude mcp add udacity-commit -- npx -y mcp-udacity-commit
19
+ ```
20
+
21
+ For Claude Desktop, add to `claude_desktop_config.json`:
22
+
23
+ ```json
24
+ {
25
+ "mcpServers": {
26
+ "udacity-commit": {
27
+ "command": "npx",
28
+ "args": ["-y", "mcp-udacity-commit"]
29
+ }
30
+ }
31
+ }
32
+ ```
33
+
34
+ ## Install from source
35
+
36
+ ```bash
37
+ git clone https://github.com/qwertymuzaffar/mcp-udacity-commit
38
+ cd mcp-udacity-commit
39
+ npm install
40
+ npm run build
41
+ claude mcp add udacity-commit -- node "$(pwd)/build/index.js"
42
+ ```
43
+
44
+ ## Develop
45
+
46
+ ```bash
47
+ npm install
48
+ npm run build # → build/index.js
49
+ npm run test:client # spawns the server and exercises the tools
50
+ ```
51
+
52
+ ## Publish
53
+
54
+ ```bash
55
+ # 1. npm
56
+ npm publish --access public
57
+
58
+ # 2. MCP Registry (after npm publish)
59
+ mcp-publisher login github
60
+ mcp-publisher publish
61
+ ```
62
+
63
+ ## License
64
+
65
+ MIT
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/build/index.js ADDED
@@ -0,0 +1,159 @@
1
+ #!/usr/bin/env node
2
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
+ import { z } from "zod";
5
+ const SUBJECT_MAX = 50;
6
+ const BODY_WRAP = 72;
7
+ const TYPES = {
8
+ feat: "A new feature",
9
+ fix: "A bug fix",
10
+ docs: "Changes to documentation",
11
+ style: "Formatting, missing semicolons, etc; no code change",
12
+ refactor: "Refactoring production code",
13
+ test: "Adding tests, refactoring tests; no production code change",
14
+ chore: "Updating build tasks, package configs, etc; no production code change",
15
+ };
16
+ const STYLE_GUIDE = `# Udacity Git Commit Message Style Guide
17
+
18
+ A commit message has three parts separated by blank lines: **subject**, optional **body**, optional **footer**.
19
+
20
+ type: Subject
21
+
22
+ Body — the what and why, not the how.
23
+
24
+ Resolves: #123
25
+ See also: #456, #789
26
+
27
+ ## Types
28
+ ${Object.entries(TYPES)
29
+ .map(([t, d]) => `- **${t}**: ${d}`)
30
+ .join("\n")}
31
+
32
+ ## Subject
33
+ - \`type: Subject\` format
34
+ - No more than ${SUBJECT_MAX} characters
35
+ - Begins with a capital letter
36
+ - Imperative mood ("Add", not "Added")
37
+ - No trailing period
38
+ - Blank line separates it from the body
39
+
40
+ ## Body (optional)
41
+ - Only when the commit needs explanation
42
+ - Explains the **what** and **why**, not the how
43
+ - Wrap each line at ${BODY_WRAP} characters
44
+
45
+ ## Footer (optional)
46
+ - References issue-tracker IDs: \`Resolves: #123\`, \`See also: #456, #789\`
47
+ `;
48
+ /** Greedy word-wrap that preserves existing paragraph breaks. */
49
+ function wrap(text, width) {
50
+ return text
51
+ .split("\n")
52
+ .map((para) => {
53
+ const words = para.split(/\s+/).filter(Boolean);
54
+ const lines = [];
55
+ let line = "";
56
+ for (const w of words) {
57
+ if (!line)
58
+ line = w;
59
+ else if ((line + " " + w).length <= width)
60
+ line += " " + w;
61
+ else {
62
+ lines.push(line);
63
+ line = w;
64
+ }
65
+ }
66
+ if (line)
67
+ lines.push(line);
68
+ return lines.join("\n");
69
+ })
70
+ .join("\n");
71
+ }
72
+ function validate(message) {
73
+ const problems = [];
74
+ const warnings = [];
75
+ const lines = message.replace(/\s+$/, "").split("\n");
76
+ const subject = lines[0] ?? "";
77
+ const m = subject.match(/^(\w+): (.*)$/);
78
+ if (!m) {
79
+ problems.push(`Subject must follow "type: Subject". Got: "${subject}".`);
80
+ }
81
+ else {
82
+ const [, type, rest] = m;
83
+ if (!TYPES[type]) {
84
+ problems.push(`Unknown type "${type}". Use one of: ${Object.keys(TYPES).join(", ")}.`);
85
+ }
86
+ if (!rest) {
87
+ problems.push("Subject text is empty after the type.");
88
+ }
89
+ else {
90
+ if (!/^[A-Z]/.test(rest)) {
91
+ problems.push(`Subject should begin with a capital letter (got "${rest[0]}").`);
92
+ }
93
+ const first = rest.split(/\s+/)[0];
94
+ if (/(ed|ing)$/i.test(first)) {
95
+ warnings.push(`"${first}" looks past-tense/gerund — use imperative mood ("Add", not "Added").`);
96
+ }
97
+ }
98
+ }
99
+ if (/\.$/.test(subject))
100
+ problems.push("Subject must not end with a period.");
101
+ if (subject.length > SUBJECT_MAX) {
102
+ problems.push(`Subject is ${subject.length} chars; max is ${SUBJECT_MAX}.`);
103
+ }
104
+ if (lines.length > 1 && lines[1].trim() !== "") {
105
+ problems.push("Leave a blank line between the subject and the body.");
106
+ }
107
+ for (let i = 2; i < lines.length; i++) {
108
+ if (lines[i].length > BODY_WRAP) {
109
+ problems.push(`Line ${i + 1} is ${lines[i].length} chars; wrap body/footer at ${BODY_WRAP}.`);
110
+ }
111
+ }
112
+ return { valid: problems.length === 0, problems, warnings };
113
+ }
114
+ const server = new McpServer({ name: "udacity-commit", version: "1.0.0" });
115
+ server.registerResource("styleguide", "udacity://commit-styleguide", {
116
+ title: "Udacity Git Commit Style Guide",
117
+ description: "The commit-message rules (types, subject, body, footer).",
118
+ mimeType: "text/markdown",
119
+ }, async (uri) => ({ contents: [{ uri: uri.href, text: STYLE_GUIDE }] }));
120
+ server.registerTool("validate_commit_message", {
121
+ title: "Validate a commit message",
122
+ description: "Check a commit message against the Udacity Git Commit Message Style Guide.",
123
+ inputSchema: { message: z.string().describe("The full commit message to check") },
124
+ }, async ({ message }) => {
125
+ const r = validate(message);
126
+ const out = [
127
+ r.valid ? "✅ Compliant with the Udacity style guide." : "❌ Not compliant.",
128
+ ...r.problems.map((p) => ` • ${p}`),
129
+ ...r.warnings.map((w) => ` ⚠ ${w}`),
130
+ ].join("\n");
131
+ return { content: [{ type: "text", text: out }] };
132
+ });
133
+ server.registerTool("format_commit_message", {
134
+ title: "Format a Udacity-style commit message",
135
+ description: "Compose a compliant commit message from its parts.",
136
+ inputSchema: {
137
+ type: z.enum(["feat", "fix", "docs", "style", "refactor", "test", "chore"]),
138
+ subject: z
139
+ .string()
140
+ .describe("Imperative subject; auto-capitalized, trailing period removed"),
141
+ body: z.string().optional().describe("What & why; auto-wrapped at 72 chars"),
142
+ footer: z.string().optional().describe('Issue refs, e.g. "Resolves: #123"'),
143
+ },
144
+ }, async ({ type, subject, body, footer }) => {
145
+ let s = subject.trim().replace(/\.+$/, "");
146
+ s = s.charAt(0).toUpperCase() + s.slice(1);
147
+ const parts = [`${type}: ${s}`];
148
+ if (body?.trim())
149
+ parts.push("", wrap(body.trim(), BODY_WRAP));
150
+ if (footer?.trim())
151
+ parts.push("", footer.trim());
152
+ const msg = parts.join("\n");
153
+ const v = validate(msg);
154
+ const note = v.valid ? "✅ compliant" : "❌ " + v.problems.join("; ");
155
+ return { content: [{ type: "text", text: `${msg}\n\n--- ${note}` }] };
156
+ });
157
+ const transport = new StdioServerTransport();
158
+ await server.connect(transport);
159
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,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AAK,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,WAAW,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC;AACxE,CAAC,CACF,CAAC;AAEF,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "mcp-udacity-commit",
3
+ "version": "1.0.0",
4
+ "description": "MCP server that validates and formats git commit messages per the Udacity Git Commit Message Style Guide.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "Muzaffar Qosimov <qwertymuzaffar@gmail.com>",
8
+ "mcpName": "io.github.qwertymuzaffar/udacity-commit",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/qwertymuzaffar/mcp-udacity-commit.git"
12
+ },
13
+ "keywords": [
14
+ "mcp",
15
+ "modelcontextprotocol",
16
+ "git",
17
+ "commit",
18
+ "udacity",
19
+ "claude"
20
+ ],
21
+ "bin": {
22
+ "mcp-udacity-commit": "./build/index.js"
23
+ },
24
+ "files": [
25
+ "build",
26
+ "README.md"
27
+ ],
28
+ "engines": {
29
+ "node": ">=18"
30
+ },
31
+ "scripts": {
32
+ "build": "tsc && chmod 755 build/index.js",
33
+ "start": "node build/index.js",
34
+ "prepublishOnly": "npm run build",
35
+ "test:client": "node test-client.mjs"
36
+ },
37
+ "dependencies": {
38
+ "@modelcontextprotocol/sdk": "^1.30.0",
39
+ "zod": "^3.25.76"
40
+ },
41
+ "devDependencies": {
42
+ "@types/node": "^26.1.2",
43
+ "typescript": "^7.0.2"
44
+ }
45
+ }