-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathmcp-server.mdc
More file actions
171 lines (135 loc) · 4.82 KB
/
mcp-server.mdc
File metadata and controls
171 lines (135 loc) · 4.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
---
description: Doughnut MCP server — structure, build, tests, Cursor/IDE configuration
alwaysApply: false
---
# doughnut-mcp-server MCP Server
A Model Context Protocol server for Doughnut.
Is in the `mcp-server` folder.
This is a TypeScript-based MCP server that demonstrates core MCP concepts by providing:
- Tools for getting instructions and updating note text content via the Doughnut backend API.
## Structure (minimal)
```
mcp-server/
src/ # Production source code
index.ts # boot: create context, start stdio
server.ts # assemble server, list tools, route calls
context.ts # read env, create DoughnutApi
api.ts # DoughnutApi factory
schemas.ts # tool input schemas (shared)
tools/index.ts # tool registry + handlers
types.ts # shared types
utils.ts # error + validation helpers
tests/ # Unit tests (separate from production code)
server.test.ts # Server and tools tests
utils.test.ts # Utility functions tests
vitest.config.ts # Test configuration
tsconfig.json # TypeScript configuration
package.json # Dependencies and scripts
```
**Important**: Tests are kept in a separate `tests/` folder, not mixed with production code in the `src/` folder. This maintains clean separation between production and test code, making the codebase more organized and maintainable.
## Development
### Building the MCP Server
Run this command to build the mcp server:
```sh
CURSOR_DEV=true nix develop -c pnpm mcp-server:bundle
```
Note: Rebuild the bundle before running the e2e `mcp_services.feature`.
### Running Unit Tests
The MCP server has comprehensive unit tests using Vitest. **Tests are located in the `tests/` folder**, not mixed with production code. Run tests with:
```sh
CURSOR_DEV=true nix develop -c pnpm mcp-server:test
```
Or from the root directory:
```sh
CURSOR_DEV=true nix develop -c pnpm mcp-server:test
```
### Test Organization
- **Production code**: Located in `src/` folder
- **Test files**: Located in `tests/` folder with `.test.ts` extension
- **Test configuration**: `vitest.config.ts` points to `tests/**/*.test.ts`
- **TypeScript config**: `tsconfig.json` includes both `src/` and `tests/` folders
This separation ensures:
- Clean, organized codebase structure
- Easy identification of production vs. test code
- Better maintainability and readability
- Standard practice followed by most TypeScript projects
### Formatting Code
Format the MCP server code with:
```sh
CURSOR_DEV=true nix develop -c pnpm mcp-server:format
```
### Test Coverage
The unit tests cover:
- Utility functions (error handling, parameter validation, environment configuration)
- Server configuration and tool definitions
- Tool schema validation
- Response format validation
- Behavior-focused assertions that are insensitive to internal structure
## CI/CD Integration
- Unit tests run as part of the "Frontend & MCP Unit Tests" job in GitHub Actions
- Formatting is included in the `pnpm format:all` command
- Tests are automatically executed on every push to main branch
## How to use this MCP Server
Add the below command to your AI MCP Server configuration.
For Cursor:
```json
{
"mcpServers": {
"doughnut": {
"disabled": false,
"timeout": 60,
"transportType": "stdio",
"command": "node",
"args": [
"<doughnut root folder>/mcp-server/dist/mcp-server.bundle.mjs"
],
"env": {
"DOUGHNUT_API_BASE_URL": "http://localhost:9081",
"DOUGHNUT_API_AUTH_TOKEN": "your-token-here"
}
}
}
}
```
For VS Code (you need to put the following content into `./.vscode/mcp.json`):
```json
{
"servers": {
"doughnut": {
"command": "node",
"args": [
"<doughnut root folder>/mcp-server/dist/mcp-server.bundle.mjs"
],
"env": {
"DOUGHNUT_API_BASE_URL": "http://localhost:9081",
"DOUGHNUT_API_AUTH_TOKEN": "your-token-here"
}
}
}
}
For IntelliJ IDE you need to go to the general settings/tools/GitHub Copilot/MCP and press configure:
```json
{
"servers": {
"doughnut": {
"disabled": false,
"timeout": 60,
"transportType": "stdio",
"command": "node",
"args": [
"<doughnut root folder>/mcp-server/dist/mcp-server.bundle.mjs"
],
"env": {
"DOUGHNUT_API_BASE_URL": "http://localhost:9081",
"DOUGHNUT_API_AUTH_TOKEN": "your-token-here"
}
}
}
}
```
## Available Tools
- `update_note_text_content` - Update the title and/or details of a note by note ID
- `get_notebook_list` - Get list of user's notebooks
- `get_graph_with_note_id` - Get graph data for a specific note
- `add_note` - Add a note to a notebook
- `get_relevant_note` - Search for relevant notes based on a query