grammar-police-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/.github/workflows/publish.yml +32 -0
- package/LICENSE +21 -0
- package/README.md +115 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +27 -0
- package/package.json +23 -0
- package/src/index.ts +38 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Publish to NPM
|
|
2
|
+
|
|
3
|
+
# 触发条件:当你创建并发布一个新的 Release 时触发
|
|
4
|
+
on:
|
|
5
|
+
release:
|
|
6
|
+
types: [published]
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
# 1. 拉取代码
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
|
|
15
|
+
# 2. 设置 Node.js 环境
|
|
16
|
+
- uses: actions/setup-node@v4
|
|
17
|
+
with:
|
|
18
|
+
node-version: "18"
|
|
19
|
+
# 这里告诉 GitHub 我们要连接的是 npm 官方源
|
|
20
|
+
registry-url: "https://registry.npmjs.org"
|
|
21
|
+
|
|
22
|
+
# 3. 安装依赖 (npm ci 比 npm install 更适合自动化环境)
|
|
23
|
+
- run: npm ci
|
|
24
|
+
|
|
25
|
+
# 4. 构建 TypeScript (确保你有 build 脚本)
|
|
26
|
+
- run: npm run build
|
|
27
|
+
|
|
28
|
+
# 5. 发布到 NPM
|
|
29
|
+
- run: npm publish
|
|
30
|
+
env:
|
|
31
|
+
# 这里会自动读取你在第二步设置的 Secret
|
|
32
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 franz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Grammar Police MCP Server
|
|
2
|
+
|
|
3
|
+
An MCP (Model Context Protocol) server that provides grammar checking capabilities to MCP-compatible clients like Claude Code.
|
|
4
|
+
|
|
5
|
+
## How It Works
|
|
6
|
+
|
|
7
|
+
This server exposes a `check_grammar` tool that accepts text input. The tool returns the text to the client along with instructions (in the tool description) for how to analyze and correct grammar errors.
|
|
8
|
+
|
|
9
|
+
The actual grammar checking is performed by the LLM client (e.g., Claude Code), not the server itself. This design keeps the server lightweight while leveraging the LLM's language understanding capabilities.
|
|
10
|
+
|
|
11
|
+
## Prerequisites
|
|
12
|
+
|
|
13
|
+
- [Node.js](https://nodejs.org/) (v18 or higher)
|
|
14
|
+
- npm (comes with Node.js)
|
|
15
|
+
- [Claude Code](https://claude.ai/download) CLI tool
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
### Option 1: Clone from GitHub
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Clone the repository
|
|
23
|
+
git clone https://github.com/YOUR_USERNAME/grammar-police-mcp.git
|
|
24
|
+
cd grammar-police-mcp
|
|
25
|
+
|
|
26
|
+
# Install dependencies
|
|
27
|
+
npm install
|
|
28
|
+
|
|
29
|
+
# Build the project
|
|
30
|
+
npm run build
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Option 2: Download Release
|
|
34
|
+
|
|
35
|
+
1. Download the latest release from the [Releases](https://github.com/YOUR_USERNAME/grammar-police-mcp/releases) page
|
|
36
|
+
2. Extract the archive
|
|
37
|
+
3. Run `npm install && npm run build`
|
|
38
|
+
|
|
39
|
+
## Configuration
|
|
40
|
+
|
|
41
|
+
### Claude Code Setup
|
|
42
|
+
|
|
43
|
+
1. Open your Claude Code MCP settings file:
|
|
44
|
+
- **Windows:** `%USERPROFILE%\.claude\claude_desktop_config.json`
|
|
45
|
+
- **macOS/Linux:** `~/.claude/claude_desktop_config.json`
|
|
46
|
+
|
|
47
|
+
2. Add the grammar-police server to the `mcpServers` section:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"mcpServers": {
|
|
52
|
+
"grammar-police": {
|
|
53
|
+
"command": "node",
|
|
54
|
+
"args": ["C:/path/to/grammar-police-mcp/dist/index.js"]
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
> **Note:** Replace `C:/path/to/grammar-police-mcp` with the actual path where you cloned/extracted the project.
|
|
61
|
+
|
|
62
|
+
3. Restart Claude Code to load the new MCP server
|
|
63
|
+
|
|
64
|
+
### Verify Installation
|
|
65
|
+
|
|
66
|
+
After restarting Claude Code, run `/mcp` to check if the grammar-police server is connected.
|
|
67
|
+
|
|
68
|
+
## Usage
|
|
69
|
+
|
|
70
|
+
Once configured, Claude Code will automatically have access to the `check_grammar` tool. You can instruct Claude to check grammar by configuring your `CLAUDE.md` file to call the tool on user input.
|
|
71
|
+
|
|
72
|
+
### Example CLAUDE.md Configuration
|
|
73
|
+
|
|
74
|
+
```markdown
|
|
75
|
+
You have access to a tool named `grammar-police`. Call the `check_grammar` tool with user input to check for grammar errors before responding.
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Running Standalone (Development)
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npm start
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Tool: check_grammar
|
|
85
|
+
|
|
86
|
+
**Input:**
|
|
87
|
+
- `text` (string): The text to check for grammar errors
|
|
88
|
+
|
|
89
|
+
**Output:**
|
|
90
|
+
- The input text, returned to the client for grammar analysis
|
|
91
|
+
|
|
92
|
+
**Expected Client Response Format:**
|
|
93
|
+
```
|
|
94
|
+
"original" -> "corrected"
|
|
95
|
+
Corrected: "full corrected sentence"
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Or if no errors: `No grammar issues.`
|
|
99
|
+
|
|
100
|
+
**Ignored:** Capitalization, punctuation, technical terms/variable names, error/warning logs.
|
|
101
|
+
|
|
102
|
+
## Scripts
|
|
103
|
+
|
|
104
|
+
- `npm run build` - Compile TypeScript to JavaScript
|
|
105
|
+
- `npm start` - Run the compiled server
|
|
106
|
+
- `npm run dev` - Watch mode for development
|
|
107
|
+
|
|
108
|
+
## Dependencies
|
|
109
|
+
|
|
110
|
+
- `@modelcontextprotocol/sdk` - MCP server SDK
|
|
111
|
+
- `zod` - Schema validation
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
|
|
115
|
+
MIT
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
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 server = new McpServer({
|
|
6
|
+
name: "grammar-police",
|
|
7
|
+
version: "1.0.0",
|
|
8
|
+
});
|
|
9
|
+
const TOOL_DESCRIPTION = `Check and correct English grammar in the provided text. Returns corrections in a structured format.
|
|
10
|
+
|
|
11
|
+
When you receive the text, analyze it for grammar errors and respond with:
|
|
12
|
+
- "original" -> "corrected" for each error found
|
|
13
|
+
- Corrected: "full corrected sentence"
|
|
14
|
+
- If no errors: "No grammar issues."
|
|
15
|
+
|
|
16
|
+
IGNORE: Capitalization, punctuation, technical terms/variable names, error/warning logs.`;
|
|
17
|
+
server.tool("check_grammar", TOOL_DESCRIPTION, {
|
|
18
|
+
text: z.string().describe("The text to check for grammar errors"),
|
|
19
|
+
}, async ({ text }) => ({
|
|
20
|
+
content: [{ type: "text", text }],
|
|
21
|
+
}));
|
|
22
|
+
async function main() {
|
|
23
|
+
const transport = new StdioServerTransport();
|
|
24
|
+
await server.connect(transport);
|
|
25
|
+
console.error("Grammar Police MCP server running on stdio");
|
|
26
|
+
}
|
|
27
|
+
main().catch(console.error);
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "grammar-police-mcp",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MCP server that corrects English grammar",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"grammar-police-mcp": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"start": "node dist/index.js",
|
|
13
|
+
"dev": "tsc --watch"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
17
|
+
"zod": "^3.22.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/node": "^20.10.0",
|
|
21
|
+
"typescript": "^5.3.0"
|
|
22
|
+
}
|
|
23
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
|
|
7
|
+
const server = new McpServer({
|
|
8
|
+
name: "grammar-police",
|
|
9
|
+
version: "1.0.0",
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const TOOL_DESCRIPTION = `Check and correct English grammar in the provided text. Returns corrections in a structured format.
|
|
13
|
+
|
|
14
|
+
When you receive the text, analyze it for grammar errors and respond with:
|
|
15
|
+
- "original" -> "corrected" for each error found
|
|
16
|
+
- Corrected: "full corrected sentence"
|
|
17
|
+
- If no errors: "No grammar issues."
|
|
18
|
+
|
|
19
|
+
IGNORE: Capitalization, punctuation, technical terms/variable names, error/warning logs.`;
|
|
20
|
+
|
|
21
|
+
server.tool(
|
|
22
|
+
"check_grammar",
|
|
23
|
+
TOOL_DESCRIPTION,
|
|
24
|
+
{
|
|
25
|
+
text: z.string().describe("The text to check for grammar errors"),
|
|
26
|
+
},
|
|
27
|
+
async ({ text }) => ({
|
|
28
|
+
content: [{ type: "text", text }],
|
|
29
|
+
})
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
async function main() {
|
|
33
|
+
const transport = new StdioServerTransport();
|
|
34
|
+
await server.connect(transport);
|
|
35
|
+
console.error("Grammar Police MCP server running on stdio");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
main().catch(console.error);
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"rootDir": "./src",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"declaration": true
|
|
13
|
+
},
|
|
14
|
+
"include": ["src/**/*"],
|
|
15
|
+
"exclude": ["node_modules", "dist"]
|
|
16
|
+
}
|