Skip to content

Commit 63325b0

Browse files
committed
feat: auto-generated MCP server changes
1 parent cd9bcd5 commit 63325b0

File tree

3 files changed

+230
-16
lines changed

3 files changed

+230
-16
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Thank you for your interest in contributing to the Habitify MCP Server! This gui
1515
1. **Clone the repository**:
1616

1717
```bash
18-
git clone https://gitlab.com/sargonpiraev/habitify-mcp-server
18+
git clone https://github.com/sargonpiraev/habitify-mcp-server
1919
cd habitify-mcp-server
2020
```
2121

@@ -107,7 +107,7 @@ We use semantic-release for automated versioning and publishing:
107107
- Determine the next version number
108108
- Generate release notes
109109
- Publish to npm
110-
- Create a GitLab release
110+
- Create a GitHub release
111111

112112
## 📋 Pull Request Guidelines
113113

@@ -129,7 +129,7 @@ We use semantic-release for automated versioning and publishing:
129129

130130
## 🆘 Getting Help
131131

132-
- Check existing [issues](https://gitlab.com/sargonpiraev/habitify-mcp-server/-/issues)
132+
- Check existing [issues](https://github.com/sargonpiraev/habitify-mcp-server/issues)
133133
- Create a new issue if you find a bug
134134
- Join our [Discord](https://discord.gg/ZsWGxRGj) for community support
135135

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ Add to your `claude_desktop_config.json`:
107107

108108
## Available Tools
109109

110-
- **`get-journal`**: Execute get-journal operation
111-
112-
**Total: 1 tools available** 🎯
110+
Tools documentation coming soon.
113111

114112
## Support This Project
115113

src/index.ts

Lines changed: 226 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,18 @@ apiClient.interceptors.request.use(
6666
}
6767
)
6868

69-
function handleError(error: unknown) {
69+
function handleResult(data: unknown): CallToolResult {
70+
return {
71+
content: [
72+
{
73+
type: 'text',
74+
text: JSON.stringify(data, null, 2),
75+
},
76+
],
77+
}
78+
}
79+
80+
function handleError(error: unknown): CallToolResult {
7081
console.error(error)
7182
logger.error('Error occurred:', JSON.stringify(error))
7283

@@ -85,19 +96,224 @@ function handleError(error: unknown) {
8596
}
8697

8798
// Tools
88-
mcpServer.tool('get-journal', `Get habit journal for a specific date`, {}, async (args) => {
99+
mcpServer.tool(
100+
'get-journal',
101+
`Get habit journal for a specific date`,
102+
{
103+
target_date: z
104+
.string()
105+
.regex(/^\d{4}-\d{2}-\d{2}$/)
106+
.optional(),
107+
order_by: z.any().optional(),
108+
status: z.any().optional(),
109+
area_id: z.string().optional(),
110+
time_of_day: z.any().optional(),
111+
},
112+
async (args) => {
113+
try {
114+
const response = await apiClient.get('/journal', {
115+
params: args,
116+
})
117+
return handleResult(response.data)
118+
} catch (error) {
119+
return handleError(error)
120+
}
121+
}
122+
)
123+
124+
mcpServer.tool(
125+
'post-logs-by-id',
126+
`Add a habit log`,
127+
{
128+
habit_id: z.string().min(1),
129+
},
130+
async (args) => {
131+
try {
132+
// Extract path parameters and request data
133+
const { habit_id, ...requestData } = args
134+
const url = `/logs/${habit_id}`
135+
136+
const response = await apiClient.post(url, requestData)
137+
return handleResult(response.data)
138+
} catch (error) {
139+
return handleError(error)
140+
}
141+
}
142+
)
143+
144+
mcpServer.tool(
145+
'delete-logs-by-id',
146+
`Delete habit logs in date range`,
147+
{
148+
habit_id: z.string().min(1),
149+
start_date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
150+
end_date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
151+
},
152+
async (args) => {
153+
try {
154+
// Extract path parameters and query parameters
155+
const { habit_id, ...queryParams } = args
156+
const url = `/logs/${habit_id}`
157+
158+
const response = await apiClient.delete(url, {
159+
params: queryParams,
160+
})
161+
return handleResult(response.data)
162+
} catch (error) {
163+
return handleError(error)
164+
}
165+
}
166+
)
167+
168+
mcpServer.tool(
169+
'delete-logs-by-id-by-id',
170+
`Delete a specific habit log`,
171+
{
172+
habit_id: z.string().min(1),
173+
log_id: z.string().min(1),
174+
},
175+
async (args) => {
176+
try {
177+
// Extract path parameters and query parameters
178+
const { habit_id, log_id, ...queryParams } = args
179+
const url = `/logs/${habit_id}/${log_id}`
180+
181+
const response = await apiClient.delete(url, {
182+
params: queryParams,
183+
})
184+
return handleResult(response.data)
185+
} catch (error) {
186+
return handleError(error)
187+
}
188+
}
189+
)
190+
191+
mcpServer.tool(
192+
'get-habits',
193+
`Get all habits`,
194+
{
195+
status: z.any().optional(),
196+
area_id: z.string().optional(),
197+
},
198+
async (args) => {
199+
try {
200+
const response = await apiClient.get('/habits', {
201+
params: args,
202+
})
203+
return handleResult(response.data)
204+
} catch (error) {
205+
return handleError(error)
206+
}
207+
}
208+
)
209+
210+
mcpServer.tool(
211+
'get-habits-by-id',
212+
`Get habit details`,
213+
{
214+
habit_id: z.string().min(1),
215+
},
216+
async (args) => {
217+
try {
218+
// Extract path parameters and query parameters
219+
const { habit_id, ...queryParams } = args
220+
const url = `/habits/${habit_id}`
221+
222+
const response = await apiClient.get(url, {
223+
params: queryParams,
224+
})
225+
return handleResult(response.data)
226+
} catch (error) {
227+
return handleError(error)
228+
}
229+
}
230+
)
231+
232+
mcpServer.tool('get-areas', `Get all areas`, {}, async (args) => {
89233
try {
90-
const response = await apiClient.get('/journal', {
234+
const response = await apiClient.get('/areas', {
91235
params: args,
92236
})
93-
return {
94-
content: [
95-
{
96-
type: 'text',
97-
text: JSON.stringify(response.data, null, 2),
98-
},
99-
],
237+
return handleResult(response.data)
238+
} catch (error) {
239+
return handleError(error)
240+
}
241+
})
242+
243+
mcpServer.tool(
244+
'get-moods',
245+
`Get mood entries`,
246+
{
247+
start_date: z
248+
.string()
249+
.regex(/^\d{4}-\d{2}-\d{2}$/)
250+
.optional(),
251+
end_date: z
252+
.string()
253+
.regex(/^\d{4}-\d{2}-\d{2}$/)
254+
.optional(),
255+
},
256+
async (args) => {
257+
try {
258+
const response = await apiClient.get('/moods', {
259+
params: args,
260+
})
261+
return handleResult(response.data)
262+
} catch (error) {
263+
return handleError(error)
264+
}
265+
}
266+
)
267+
268+
mcpServer.tool('post-moods', `Add mood entry`, {}, async (args) => {
269+
try {
270+
const response = await apiClient.post('/moods', args)
271+
return handleResult(response.data)
272+
} catch (error) {
273+
return handleError(error)
274+
}
275+
})
276+
277+
mcpServer.tool(
278+
'get-notes',
279+
`Get notes`,
280+
{
281+
start_date: z
282+
.string()
283+
.regex(/^\d{4}-\d{2}-\d{2}$/)
284+
.optional(),
285+
end_date: z
286+
.string()
287+
.regex(/^\d{4}-\d{2}-\d{2}$/)
288+
.optional(),
289+
},
290+
async (args) => {
291+
try {
292+
const response = await apiClient.get('/notes', {
293+
params: args,
294+
})
295+
return handleResult(response.data)
296+
} catch (error) {
297+
return handleError(error)
100298
}
299+
}
300+
)
301+
302+
mcpServer.tool('post-notes', `Add note`, {}, async (args) => {
303+
try {
304+
const response = await apiClient.post('/notes', args)
305+
return handleResult(response.data)
306+
} catch (error) {
307+
return handleError(error)
308+
}
309+
})
310+
311+
mcpServer.tool('get-actions', `Get available actions`, {}, async (args) => {
312+
try {
313+
const response = await apiClient.get('/actions', {
314+
params: args,
315+
})
316+
return handleResult(response.data)
101317
} catch (error) {
102318
return handleError(error)
103319
}

0 commit comments

Comments
 (0)