@manhq/localmcp 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 +239 -0
- package/README.vi.md +239 -0
- package/bin/localmcp.js +31 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +333 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +102 -0
- package/dist/index.js.map +1 -0
- package/dist/services/atlassian/client.d.ts +4 -0
- package/dist/services/atlassian/client.d.ts.map +1 -0
- package/dist/services/atlassian/client.js +26 -0
- package/dist/services/atlassian/client.js.map +1 -0
- package/dist/services/atlassian/index.d.ts +3 -0
- package/dist/services/atlassian/index.d.ts.map +1 -0
- package/dist/services/atlassian/index.js +7 -0
- package/dist/services/atlassian/index.js.map +1 -0
- package/dist/services/atlassian/tools/confluence.d.ts +3 -0
- package/dist/services/atlassian/tools/confluence.d.ts.map +1 -0
- package/dist/services/atlassian/tools/confluence.js +222 -0
- package/dist/services/atlassian/tools/confluence.js.map +1 -0
- package/dist/services/atlassian/tools/jira.d.ts +3 -0
- package/dist/services/atlassian/tools/jira.d.ts.map +1 -0
- package/dist/services/atlassian/tools/jira.js +266 -0
- package/dist/services/atlassian/tools/jira.js.map +1 -0
- package/dist/services/atlassian/types.d.ts +74 -0
- package/dist/services/atlassian/types.d.ts.map +1 -0
- package/dist/services/atlassian/types.js +2 -0
- package/dist/services/atlassian/types.js.map +1 -0
- package/dist/services/figma/client.d.ts +3 -0
- package/dist/services/figma/client.d.ts.map +1 -0
- package/dist/services/figma/client.js +27 -0
- package/dist/services/figma/client.js.map +1 -0
- package/dist/services/figma/index.d.ts +3 -0
- package/dist/services/figma/index.d.ts.map +1 -0
- package/dist/services/figma/index.js +13 -0
- package/dist/services/figma/index.js.map +1 -0
- package/dist/services/figma/tools/comments.d.ts +3 -0
- package/dist/services/figma/tools/comments.d.ts.map +1 -0
- package/dist/services/figma/tools/comments.js +41 -0
- package/dist/services/figma/tools/comments.js.map +1 -0
- package/dist/services/figma/tools/components.d.ts +3 -0
- package/dist/services/figma/tools/components.d.ts.map +1 -0
- package/dist/services/figma/tools/components.js +101 -0
- package/dist/services/figma/tools/components.js.map +1 -0
- package/dist/services/figma/tools/files.d.ts +3 -0
- package/dist/services/figma/tools/files.d.ts.map +1 -0
- package/dist/services/figma/tools/files.js +86 -0
- package/dist/services/figma/tools/files.js.map +1 -0
- package/dist/services/figma/tools/images.d.ts +3 -0
- package/dist/services/figma/tools/images.d.ts.map +1 -0
- package/dist/services/figma/tools/images.js +67 -0
- package/dist/services/figma/tools/images.js.map +1 -0
- package/dist/services/figma/tools/variables.d.ts +3 -0
- package/dist/services/figma/tools/variables.d.ts.map +1 -0
- package/dist/services/figma/tools/variables.js +44 -0
- package/dist/services/figma/tools/variables.js.map +1 -0
- package/dist/services/figma/types.d.ts +65 -0
- package/dist/services/figma/types.d.ts.map +1 -0
- package/dist/services/figma/types.js +2 -0
- package/dist/services/figma/types.js.map +1 -0
- package/dist/services/google-chat/auth.d.ts +2 -0
- package/dist/services/google-chat/auth.d.ts.map +1 -0
- package/dist/services/google-chat/auth.js +18 -0
- package/dist/services/google-chat/auth.js.map +1 -0
- package/dist/services/google-chat/client.d.ts +3 -0
- package/dist/services/google-chat/client.d.ts.map +1 -0
- package/dist/services/google-chat/client.js +14 -0
- package/dist/services/google-chat/client.js.map +1 -0
- package/dist/services/google-chat/index.d.ts +3 -0
- package/dist/services/google-chat/index.d.ts.map +1 -0
- package/dist/services/google-chat/index.js +5 -0
- package/dist/services/google-chat/index.js.map +1 -0
- package/dist/services/google-chat/tools/messages.d.ts +3 -0
- package/dist/services/google-chat/tools/messages.d.ts.map +1 -0
- package/dist/services/google-chat/tools/messages.js +144 -0
- package/dist/services/google-chat/tools/messages.js.map +1 -0
- package/dist/services/google-chat/types.d.ts +31 -0
- package/dist/services/google-chat/types.d.ts.map +1 -0
- package/dist/services/google-chat/types.js +2 -0
- package/dist/services/google-chat/types.js.map +1 -0
- package/dist/shared/env.d.ts +18 -0
- package/dist/shared/env.d.ts.map +1 -0
- package/dist/shared/env.js +27 -0
- package/dist/shared/env.js.map +1 -0
- package/dist/shared/errors.d.ts +8 -0
- package/dist/shared/errors.d.ts.map +1 -0
- package/dist/shared/errors.js +38 -0
- package/dist/shared/errors.js.map +1 -0
- package/dist/shared/response.d.ts +7 -0
- package/dist/shared/response.d.ts.map +1 -0
- package/dist/shared/response.js +7 -0
- package/dist/shared/response.js.map +1 -0
- package/dist/shared/settings.d.ts +36 -0
- package/dist/shared/settings.d.ts.map +1 -0
- package/dist/shared/settings.js +104 -0
- package/dist/shared/settings.js.map +1 -0
- package/docs/atlassian.md +170 -0
- package/docs/figma.md +154 -0
- package/docs/google-chat.md +130 -0
- package/docs/vi/atlassian.md +170 -0
- package/docs/vi/figma.md +154 -0
- package/docs/vi/google-chat.md +130 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# Local MCP Server
|
|
2
|
+
|
|
3
|
+
[English](README.md) | [Tiếng Việt](README.vi.md)
|
|
4
|
+
|
|
5
|
+
Self-hosted MCP server integrating Figma, Jira, and Google Chat for AI agents.
|
|
6
|
+
|
|
7
|
+
## Requirements
|
|
8
|
+
|
|
9
|
+
- Node.js 20+ (LTS)
|
|
10
|
+
- npm 10+
|
|
11
|
+
|
|
12
|
+
## Install & Run
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# Install dependencies
|
|
16
|
+
npm install
|
|
17
|
+
|
|
18
|
+
# Create the configuration file
|
|
19
|
+
cp .env.example .env
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Fill credentials in `.env` (see each service doc below), then:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Run in dev mode with auto reload
|
|
26
|
+
npm run dev
|
|
27
|
+
|
|
28
|
+
# Build & run production
|
|
29
|
+
npm run build
|
|
30
|
+
npm start
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The server runs at `http://localhost:47001` by default.
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Open MCP Inspector while the server is running
|
|
37
|
+
npm run inspect
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Flexible Run
|
|
41
|
+
|
|
42
|
+
If you do not want to open the project every time, register a global command while developing locally:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm run build
|
|
46
|
+
npm link
|
|
47
|
+
localmcp
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
After `npm link`, the `localmcp` command works from any directory.
|
|
51
|
+
|
|
52
|
+
After publishing to npm, users can install it with:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm install -g @manhq/localmcp
|
|
56
|
+
localmcp init
|
|
57
|
+
localmcp config
|
|
58
|
+
localmcp
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Default settings path:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
~/localmcp/settings.json
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Main commands:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
localmcp # Run the MCP server
|
|
71
|
+
localmcp init # Create settings for the first time
|
|
72
|
+
localmcp list # List services and missing variables
|
|
73
|
+
localmcp config # Open settings with vim or $EDITOR
|
|
74
|
+
localmcp config figma # Configure Figma with inline prompts
|
|
75
|
+
localmcp config figma token=figd_xxx
|
|
76
|
+
localmcp register # Select AI agent, then localmcp or a service
|
|
77
|
+
localmcp register codex --service figma
|
|
78
|
+
localmcp inspect # Open MCP Inspector
|
|
79
|
+
localmcp --version # Show version
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Environment variables still take precedence over the settings file, so quick overrides work:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
PORT=47002 localmcp
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Publish package:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npm publish --access=public
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Register with AI Agents
|
|
95
|
+
|
|
96
|
+
**Claude Code** — `.claude/settings.local.json`
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"mcpServers": {
|
|
100
|
+
"localmcp": {
|
|
101
|
+
"url": "http://localhost:47001/mcp"
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Or register from the command line:
|
|
108
|
+
```bash
|
|
109
|
+
claude mcp add --transport http localmcp http://localhost:47001/mcp
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Codex** — `~/.codex/config.toml`
|
|
113
|
+
```toml
|
|
114
|
+
[mcp_servers.localmcp]
|
|
115
|
+
url = "http://localhost:47001/mcp"
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Or register from the command line:
|
|
119
|
+
```bash
|
|
120
|
+
codex mcp add localmcp --url http://localhost:47001/mcp
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**GitHub Copilot / VS Code** — `.vscode/mcp.json`
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"servers": {
|
|
127
|
+
"localmcp": {
|
|
128
|
+
"type": "http",
|
|
129
|
+
"url": "http://localhost:47001/mcp"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Cursor** — `.cursor/mcp.json`
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"mcpServers": {
|
|
139
|
+
"localmcp": {
|
|
140
|
+
"url": "http://localhost:47001/mcp"
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**Windsurf** — `~/.codeium/windsurf/mcp_config.json`
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"mcpServers": {
|
|
150
|
+
"localmcp": {
|
|
151
|
+
"serverUrl": "http://localhost:47001/mcp"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Antigravity** — `~/.gemini/config/mcp_config.json`
|
|
158
|
+
```json
|
|
159
|
+
{
|
|
160
|
+
"mcpServers": {
|
|
161
|
+
"localmcp": {
|
|
162
|
+
"serverUrl": "http://localhost:47001/mcp"
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Health Check
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
GET http://localhost:47001/health
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Returns the active services and their corresponding endpoints.
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Services
|
|
179
|
+
|
|
180
|
+
| Service | Dedicated endpoint | Docs |
|
|
181
|
+
|---------|--------------------|------|
|
|
182
|
+
| Figma | `/mcp/figma` | [EN](docs/figma.md) / [VI](docs/vi/figma.md) |
|
|
183
|
+
| Atlassian | `/mcp/atlassian` | [EN](docs/atlassian.md) / [VI](docs/vi/atlassian.md) |
|
|
184
|
+
| Google Chat | `/mcp/google-chat` | [EN](docs/google-chat.md) / [VI](docs/vi/google-chat.md) |
|
|
185
|
+
|
|
186
|
+
The `/mcp` endpoint is combined: it exposes every active service through one server.
|
|
187
|
+
|
|
188
|
+
Each service is enabled only when all required environment variables are present. See each service doc for required variables.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Add a New Service
|
|
193
|
+
|
|
194
|
+
### 1. Create the Folder Structure
|
|
195
|
+
|
|
196
|
+
```
|
|
197
|
+
src/services/<service-name>/
|
|
198
|
+
index.ts # exports registerXxxTools(server)
|
|
199
|
+
client.ts # axios client or SDK wrapper
|
|
200
|
+
types.ts # TypeScript types
|
|
201
|
+
tools/
|
|
202
|
+
<feature>.ts # registers tools with server.registerTool(...)
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### 2. Register it in the Service Registry
|
|
206
|
+
|
|
207
|
+
Open `src/index.ts`, then add it to `SERVICE_REGISTRY`:
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
import { registerXxxTools } from "./services/xxx/index.js";
|
|
211
|
+
|
|
212
|
+
const SERVICE_REGISTRY = {
|
|
213
|
+
// ...existing services...
|
|
214
|
+
xxx: { register: registerXxxTools, enabled: !!env.xxx },
|
|
215
|
+
};
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### 3. Add Environment Variables
|
|
219
|
+
|
|
220
|
+
Open `src/shared/env.ts`, then add a new optional group:
|
|
221
|
+
|
|
222
|
+
```ts
|
|
223
|
+
export const env = {
|
|
224
|
+
// ...
|
|
225
|
+
xxx: optionalGroup(["XXX_API_KEY"], () => ({
|
|
226
|
+
API_KEY: process.env["XXX_API_KEY"]!,
|
|
227
|
+
})),
|
|
228
|
+
};
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Add it to `.env.example`:
|
|
232
|
+
|
|
233
|
+
```
|
|
234
|
+
XXX_API_KEY=
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### 4. Write Documentation
|
|
238
|
+
|
|
239
|
+
Create `docs/<service-name>.md` and `docs/vi/<service-name>.md`, then add the service to the **Services** table in both README files.
|
package/README.vi.md
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# Local MCP Server
|
|
2
|
+
|
|
3
|
+
[English](README.md) | [Tiếng Việt](README.vi.md)
|
|
4
|
+
|
|
5
|
+
MCP server tự host, tích hợp Figma, Jira và Google Chat cho các AI agent.
|
|
6
|
+
|
|
7
|
+
## Yêu cầu
|
|
8
|
+
|
|
9
|
+
- Node.js 20+ (LTS)
|
|
10
|
+
- npm 10+
|
|
11
|
+
|
|
12
|
+
## Cài đặt & chạy
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# Cài dependencies
|
|
16
|
+
npm install
|
|
17
|
+
|
|
18
|
+
# Tạo file cấu hình
|
|
19
|
+
cp .env.example .env
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Điền credentials vào `.env` (xem tài liệu từng service bên dưới), sau đó:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Chạy ở chế độ dev (tự reload khi sửa code)
|
|
26
|
+
npm run dev
|
|
27
|
+
|
|
28
|
+
# Build & chạy production
|
|
29
|
+
npm run build
|
|
30
|
+
npm start
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Server mặc định chạy tại `http://localhost:47001`.
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Mở MCP Inspector (chạy song song với server)
|
|
37
|
+
npm run inspect
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Chạy linh hoạt
|
|
41
|
+
|
|
42
|
+
Nếu không muốn mở project mỗi lần chạy, có thể đăng ký command global khi đang phát triển local:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm run build
|
|
46
|
+
npm link
|
|
47
|
+
localmcp
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Sau khi `npm link`, lệnh `localmcp` chạy được ở bất kỳ thư mục nào.
|
|
51
|
+
|
|
52
|
+
Khi publish lên npm, người dùng có thể cài bằng:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm install -g @manhq/localmcp
|
|
56
|
+
localmcp init
|
|
57
|
+
localmcp config
|
|
58
|
+
localmcp
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Settings mặc định nằm ở:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
~/localmcp/settings.json
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Các command chính:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
localmcp # Chạy MCP server
|
|
71
|
+
localmcp init # Tạo settings lần đầu
|
|
72
|
+
localmcp list # Liệt kê services và biến còn thiếu
|
|
73
|
+
localmcp config # Mở settings bằng vim hoặc $EDITOR
|
|
74
|
+
localmcp config figma # Config riêng service Figma bằng prompt inline
|
|
75
|
+
localmcp config figma token=figd_xxx
|
|
76
|
+
localmcp register # Chọn AI agent, sau đó chọn localmcp hoặc service
|
|
77
|
+
localmcp register codex --service figma
|
|
78
|
+
localmcp inspect # Mở MCP Inspector
|
|
79
|
+
localmcp --version # Xem phiên bản
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Biến môi trường vẫn được ưu tiên cao hơn settings file, nên có thể override nhanh:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
PORT=47002 localmcp
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Publish package:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npm publish --access=public
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Đăng ký với AI Agents
|
|
95
|
+
|
|
96
|
+
**Claude Code** — `.claude/settings.local.json`
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"mcpServers": {
|
|
100
|
+
"localmcp": {
|
|
101
|
+
"url": "http://localhost:47001/mcp"
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Hoặc đăng ký bằng command line:
|
|
108
|
+
```bash
|
|
109
|
+
claude mcp add --transport http localmcp http://localhost:47001/mcp
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Codex** — `~/.codex/config.toml`
|
|
113
|
+
```toml
|
|
114
|
+
[mcp_servers.localmcp]
|
|
115
|
+
url = "http://localhost:47001/mcp"
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Hoặc đăng ký bằng command line:
|
|
119
|
+
```bash
|
|
120
|
+
codex mcp add localmcp --url http://localhost:47001/mcp
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**GitHub Copilot / VS Code** — `.vscode/mcp.json`
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"servers": {
|
|
127
|
+
"localmcp": {
|
|
128
|
+
"type": "http",
|
|
129
|
+
"url": "http://localhost:47001/mcp"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Cursor** — `.cursor/mcp.json`
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"mcpServers": {
|
|
139
|
+
"localmcp": {
|
|
140
|
+
"url": "http://localhost:47001/mcp"
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**Windsurf** — `~/.codeium/windsurf/mcp_config.json`
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"mcpServers": {
|
|
150
|
+
"localmcp": {
|
|
151
|
+
"serverUrl": "http://localhost:47001/mcp"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Antigravity** — `~/.gemini/config/mcp_config.json`
|
|
158
|
+
```json
|
|
159
|
+
{
|
|
160
|
+
"mcpServers": {
|
|
161
|
+
"localmcp": {
|
|
162
|
+
"serverUrl": "http://localhost:47001/mcp"
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Kiểm tra trạng thái
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
GET http://localhost:47001/health
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Trả về danh sách services đang active và các endpoints tương ứng.
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Danh sách services
|
|
179
|
+
|
|
180
|
+
| Service | Endpoint riêng | Tài liệu |
|
|
181
|
+
|---------|---------------|----------|
|
|
182
|
+
| Figma | `/mcp/figma` | [EN](docs/figma.md) / [VI](docs/vi/figma.md) |
|
|
183
|
+
| Atlassian | `/mcp/atlassian` | [EN](docs/atlassian.md) / [VI](docs/vi/atlassian.md) |
|
|
184
|
+
| Google Chat | `/mcp/google-chat` | [EN](docs/google-chat.md) / [VI](docs/vi/google-chat.md) |
|
|
185
|
+
|
|
186
|
+
Endpoint `/mcp` là combined — gộp tất cả services đang active vào một server.
|
|
187
|
+
|
|
188
|
+
Mỗi service chỉ được bật khi đủ biến môi trường. Xem tài liệu từng service để biết biến nào cần thiết.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Thêm service mới
|
|
193
|
+
|
|
194
|
+
### 1. Tạo cấu trúc thư mục
|
|
195
|
+
|
|
196
|
+
```
|
|
197
|
+
src/services/<tên-service>/
|
|
198
|
+
index.ts # export registerXxxTools(server)
|
|
199
|
+
client.ts # axios client hoặc SDK wrapper
|
|
200
|
+
types.ts # TypeScript types
|
|
201
|
+
tools/
|
|
202
|
+
<feature>.ts # đăng ký tool với server.registerTool(...)
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### 2. Đăng ký vào service registry
|
|
206
|
+
|
|
207
|
+
Mở `src/index.ts`, thêm vào `SERVICE_REGISTRY`:
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
import { registerXxxTools } from "./services/xxx/index.js";
|
|
211
|
+
|
|
212
|
+
const SERVICE_REGISTRY = {
|
|
213
|
+
// ...services hiện có...
|
|
214
|
+
xxx: { register: registerXxxTools, enabled: !!env.xxx },
|
|
215
|
+
};
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### 3. Thêm biến môi trường
|
|
219
|
+
|
|
220
|
+
Mở `src/shared/env.ts`, thêm optional group mới:
|
|
221
|
+
|
|
222
|
+
```ts
|
|
223
|
+
export const env = {
|
|
224
|
+
// ...
|
|
225
|
+
xxx: optionalGroup(["XXX_API_KEY"], () => ({
|
|
226
|
+
API_KEY: process.env["XXX_API_KEY"]!,
|
|
227
|
+
})),
|
|
228
|
+
};
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Thêm vào `.env.example`:
|
|
232
|
+
|
|
233
|
+
```
|
|
234
|
+
XXX_API_KEY=
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### 4. Viết tài liệu
|
|
238
|
+
|
|
239
|
+
Tạo `docs/<tên-service>.md` theo mẫu các service hiện có, sau đó thêm dòng vào bảng **Danh sách services** ở README này.
|
package/bin/localmcp.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
import { dirname, resolve } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
8
|
+
const distEntry = resolve(packageRoot, "dist/cli.js");
|
|
9
|
+
|
|
10
|
+
const run = (command, args, cwd = process.cwd()) => {
|
|
11
|
+
const child = spawn(command, args, {
|
|
12
|
+
cwd,
|
|
13
|
+
stdio: "inherit",
|
|
14
|
+
env: process.env,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
child.on("exit", (code, signal) => {
|
|
18
|
+
if (signal) {
|
|
19
|
+
process.kill(process.pid, signal);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
process.exit(code ?? 0);
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
if (existsSync(distEntry)) {
|
|
28
|
+
run(process.execPath, [distEntry, ...process.argv.slice(2)]);
|
|
29
|
+
} else {
|
|
30
|
+
run("npx", ["tsx", "src/cli.ts", ...process.argv.slice(2)], packageRoot);
|
|
31
|
+
}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAuBA,wBAAsB,MAAM,CAAC,IAAI,WAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoCxE"}
|