Skip to content

Commit 0ab9383

Browse files
feat: add MCP tool annotations for read/write classification
Annotate all 15 tools with readOnlyHint, idempotentHint, and openWorldHint so MCP clients can distinguish read-only operations (queries, reports, listings) from write operations (start/stop timer) and local-only operations (cache management). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 434e929 commit 0ab9383

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

src/index.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,17 @@ const server = new Server(
134134
);
135135

136136
// Define tool schemas
137+
// Common annotation sets
138+
const readOnlyRemote = { readOnlyHint: true, idempotentHint: true, openWorldHint: true };
139+
const writeRemote = { readOnlyHint: false, openWorldHint: true };
140+
const readOnlyLocal = { readOnlyHint: true, idempotentHint: true, openWorldHint: false };
141+
137142
const tools: Tool[] = [
138143
// Health/authentication
139144
{
140145
name: 'toggl_check_auth',
141146
description: 'Verify Toggl API connectivity and authentication is valid',
147+
annotations: readOnlyRemote,
142148
inputSchema: {
143149
type: 'object',
144150
properties: {},
@@ -149,6 +155,7 @@ const tools: Tool[] = [
149155
{
150156
name: 'toggl_get_time_entries',
151157
description: 'Get time entries with optional date range filters. Returns hydrated entries with project/workspace names.',
158+
annotations: readOnlyRemote,
152159
inputSchema: {
153160
type: 'object',
154161
properties: {
@@ -179,6 +186,7 @@ const tools: Tool[] = [
179186
{
180187
name: 'toggl_get_current_entry',
181188
description: 'Get the currently running time entry, if any',
189+
annotations: readOnlyRemote,
182190
inputSchema: {
183191
type: 'object',
184192
properties: {},
@@ -188,6 +196,7 @@ const tools: Tool[] = [
188196
{
189197
name: 'toggl_start_timer',
190198
description: 'Start a new time entry timer',
199+
annotations: writeRemote,
191200
inputSchema: {
192201
type: 'object',
193202
properties: {
@@ -218,17 +227,19 @@ const tools: Tool[] = [
218227
{
219228
name: 'toggl_stop_timer',
220229
description: 'Stop the currently running timer',
230+
annotations: { ...writeRemote, idempotentHint: true },
221231
inputSchema: {
222232
type: 'object',
223233
properties: {},
224234
required: []
225235
},
226236
},
227-
237+
228238
// Reporting tools
229239
{
230240
name: 'toggl_daily_report',
231241
description: 'Generate a daily report with hours by project and workspace',
242+
annotations: readOnlyRemote,
232243
inputSchema: {
233244
type: 'object',
234245
properties: {
@@ -247,6 +258,7 @@ const tools: Tool[] = [
247258
{
248259
name: 'toggl_weekly_report',
249260
description: 'Generate a weekly report with daily breakdown and project summaries',
261+
annotations: readOnlyRemote,
250262
inputSchema: {
251263
type: 'object',
252264
properties: {
@@ -265,6 +277,7 @@ const tools: Tool[] = [
265277
{
266278
name: 'toggl_project_summary',
267279
description: 'Get total hours per project for a date range',
280+
annotations: readOnlyRemote,
268281
inputSchema: {
269282
type: 'object',
270283
properties: {
@@ -291,6 +304,7 @@ const tools: Tool[] = [
291304
{
292305
name: 'toggl_workspace_summary',
293306
description: 'Get total hours per workspace for a date range',
307+
annotations: readOnlyRemote,
294308
inputSchema: {
295309
type: 'object',
296310
properties: {
@@ -310,11 +324,12 @@ const tools: Tool[] = [
310324
}
311325
},
312326
},
313-
327+
314328
// Management tools
315329
{
316330
name: 'toggl_list_workspaces',
317331
description: 'List all available workspaces',
332+
annotations: readOnlyRemote,
318333
inputSchema: {
319334
type: 'object',
320335
properties: {},
@@ -324,6 +339,7 @@ const tools: Tool[] = [
324339
{
325340
name: 'toggl_list_projects',
326341
description: 'List projects for a workspace',
342+
annotations: readOnlyRemote,
327343
inputSchema: {
328344
type: 'object',
329345
properties: {
@@ -337,6 +353,7 @@ const tools: Tool[] = [
337353
{
338354
name: 'toggl_list_clients',
339355
description: 'List clients for a workspace',
356+
annotations: readOnlyRemote,
340357
inputSchema: {
341358
type: 'object',
342359
properties: {
@@ -347,11 +364,12 @@ const tools: Tool[] = [
347364
}
348365
},
349366
},
350-
367+
351368
// Cache management
352369
{
353370
name: 'toggl_warm_cache',
354371
description: 'Pre-fetch and cache workspace, project, and client data for better performance',
372+
annotations: readOnlyLocal,
355373
inputSchema: {
356374
type: 'object',
357375
properties: {
@@ -365,6 +383,7 @@ const tools: Tool[] = [
365383
{
366384
name: 'toggl_cache_stats',
367385
description: 'Get cache statistics and performance metrics',
386+
annotations: readOnlyLocal,
368387
inputSchema: {
369388
type: 'object',
370389
properties: {},
@@ -374,6 +393,7 @@ const tools: Tool[] = [
374393
{
375394
name: 'toggl_clear_cache',
376395
description: 'Clear all cached data',
396+
annotations: { readOnlyHint: false, idempotentHint: true, openWorldHint: false },
377397
inputSchema: {
378398
type: 'object',
379399
properties: {},

0 commit comments

Comments
 (0)