mcp-sunsama 0.12.1 → 0.13.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/CHANGELOG.md CHANGED
@@ -1,5 +1,45 @@
1
1
  # mcp-sunsama
2
2
 
3
+ ## 0.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - a39494b: Refactor to modular architecture with improved type safety
8
+
9
+ - **BREAKING**: Refactored codebase into modular, resource-based architecture
10
+ - **Major code organization improvements**:
11
+
12
+ - Extracted tools into separate files by resource type (user, task, stream)
13
+ - Reduced main.ts complexity by 96% (1162 → 47 lines)
14
+ - Created shared utilities for common patterns
15
+ - Moved API documentation to dedicated resources file
16
+
17
+ - **Complete type safety overhaul**:
18
+
19
+ - Eliminated all `any` types from function parameters
20
+ - Added proper TypeScript typing with Zod schema inference
21
+ - Implemented parameter destructuring for cleaner function signatures
22
+ - Added missing type exports to schemas
23
+
24
+ - **Enhanced developer experience**:
25
+
26
+ - Standardized error handling and logging across all tools
27
+ - Consistent response formatting with shared utilities
28
+ - Better code maintainability and testability
29
+ - Clear separation of concerns
30
+
31
+ - **New modular structure**:
32
+ ```
33
+ src/tools/
34
+ ├── shared.ts # Common utilities and patterns
35
+ ├── user-tools.ts # User operations
36
+ ├── task-tools.ts # Task operations (14 tools)
37
+ ├── stream-tools.ts # Stream operations
38
+ └── index.ts # Export all tools
39
+ ```
40
+
41
+ This refactoring maintains 100% API compatibility while significantly improving code quality, type safety, and maintainability.
42
+
3
43
  ## 0.12.1
4
44
 
5
45
  ### Patch Changes
package/CLAUDE.md CHANGED
@@ -72,18 +72,31 @@ All tools use Zod schemas from `schemas.ts`:
72
72
  ## Key Patterns
73
73
 
74
74
  ### Tool Structure
75
- Standard pattern for all MCP tools:
75
+ Modern tool pattern using shared utilities and parameter destructuring:
76
76
  ```typescript
77
+ // Old pattern (before refactoring)
77
78
  server.addTool({
78
79
  name: "tool-name",
79
80
  description: "...",
80
81
  parameters: toolSchema,
81
82
  execute: async (args, {session, log}) => {
82
- // 1. Extract/validate parameters
83
- // 2. Get client via getSunsamaClient(session)
83
+ const { param1, param2 } = args;
84
+ // Manual error handling, client resolution, etc.
85
+ }
86
+ });
87
+
88
+ // New pattern (current)
89
+ export const toolName = createToolWrapper({
90
+ name: "tool-name",
91
+ description: "...",
92
+ parameters: toolSchema,
93
+ execute: async ({ param1, param2 }: ToolInput, context: ToolContext) => {
94
+ // 1. Parameters automatically destructured and typed
95
+ // 2. Get client via getClient(context.session)
84
96
  // 3. Call sunsama-api methods
85
97
  // 4. Apply filtering/trimming if needed
86
- // 5. Return formatted response
98
+ // 5. Return formatted response using formatters
99
+ // Error handling and logging handled by wrapper
87
100
  }
88
101
  });
89
102
  ```
@@ -106,17 +119,50 @@ server.addTool({
106
119
 
107
120
  ## Code Organization
108
121
 
109
- - `src/main.ts`: FastMCP server setup and tool definitions
110
- - `src/schemas.ts`: Zod validation schemas for all tools
111
- - `src/schemas.test.ts`: Comprehensive test suite for all Zod schemas including parameter validation, response schemas, and XOR patterns
112
- - `src/auth/`: Authentication strategies per transport type
113
- - `src/config/`: Environment configuration and validation
114
- - `src/utils/`: Reusable utilities (client resolution, filtering, formatting)
122
+ ### Refactored Modular Architecture (2024)
123
+
124
+ The codebase has been refactored into a modular, resource-based architecture:
125
+
126
+ ```
127
+ src/
128
+ ├── tools/
129
+ │ ├── shared.ts # Common utilities and tool wrapper patterns
130
+ │ ├── user-tools.ts # User operations (get-user)
131
+ │ ├── task-tools.ts # Task operations (14 tools)
132
+ │ ├── stream-tools.ts # Stream operations (get-streams)
133
+ │ └── index.ts # Export all tools
134
+ ├── resources/
135
+ │ └── index.ts # API documentation resource
136
+ ├── auth/ # Authentication strategies per transport type
137
+ ├── config/ # Environment configuration and validation
138
+ ├── utils/ # Reusable utilities (client resolution, filtering, formatting)
139
+ ├── schemas.ts # Zod validation schemas for all tools
140
+ ├── schemas.test.ts # Comprehensive test suite for all Zod schemas
141
+ └── main.ts # Streamlined server setup (47 lines vs 1162 before)
142
+ ```
143
+
144
+ ### Tool Architecture Improvements
145
+
146
+ **Shared Utilities** (`tools/shared.ts`):
147
+ - `createToolWrapper()`: Standardized error handling and logging wrapper
148
+ - `getClient()`: Session-aware client resolution
149
+ - `formatJsonResponse()`, `formatTsvResponse()`: Consistent response formatting
150
+ - `formatPaginatedTsvResponse()`: Specialized pagination support
151
+
152
+ **Resource-Based Organization**:
153
+ - **User Tools**: Single tool for user operations
154
+ - **Task Tools**: 14 tools organized by function (query, lifecycle, update)
155
+ - **Stream Tools**: Single tool for stream operations
156
+
157
+ **Type Safety Improvements**:
158
+ - **Parameter Destructuring**: Function signatures directly destructure typed parameters
159
+ - **Zod Schema Integration**: Full TypeScript inference from Zod schemas
160
+ - **Eliminated `any` Types**: All parameters properly typed with generated types
115
161
 
116
162
  ## Important Notes
117
163
 
118
164
  ### Version Synchronization
119
- Always keep FastMCP server version in `src/main.ts` (line ~32) synchronized with `package.json` version.
165
+ Always keep FastMCP server version in `src/main.ts` (line 19) synchronized with `package.json` version.
120
166
 
121
167
  ### Environment Variables
122
168
  Required for stdio transport:
@@ -144,7 +190,7 @@ Configure different server variants in `mcp-inspector.json` for testing various
144
190
 
145
191
  When updating the version:
146
192
  1. Update `package.json` version (done automatically by changesets)
147
- 2. Manually update the FastMCP server version in `src/main.ts`
193
+ 2. Manually update the FastMCP server version in `src/main.ts` (line 19)
148
194
  3. Both versions must be identical for consistency
149
195
 
150
196
  ## Git Rules
package/README.md CHANGED
@@ -121,11 +121,40 @@ bun run inspect
121
121
 
122
122
  Then connect the MCP Inspector to test the tools interactively.
123
123
 
124
- ### Build
124
+ ### Build and Type Checking
125
125
  ```bash
126
- bun run build
126
+ bun run build # Compile TypeScript to dist/
127
+ bun run typecheck # Run TypeScript type checking
128
+ bun run typecheck:watch # Watch mode type checking
127
129
  ```
128
130
 
131
+ ### Code Architecture
132
+
133
+ The server is organized with a modular, resource-based architecture:
134
+
135
+ ```
136
+ src/
137
+ ├── tools/
138
+ │ ├── shared.ts # Common utilities and patterns
139
+ │ ├── user-tools.ts # User operations (get-user)
140
+ │ ├── task-tools.ts # Task operations (14 tools)
141
+ │ ├── stream-tools.ts # Stream operations (get-streams)
142
+ │ └── index.ts # Export all tools
143
+ ├── resources/
144
+ │ └── index.ts # API documentation resource
145
+ ├── auth/ # Authentication strategies
146
+ ├── config/ # Environment configuration
147
+ ├── utils/ # Utilities (filtering, trimming, etc.)
148
+ └── main.ts # Server setup (47 lines vs 1162 before refactoring)
149
+ ```
150
+
151
+ **Key Features:**
152
+ - **Type Safety**: Full TypeScript typing with Zod schema validation
153
+ - **Parameter Destructuring**: Clean, explicit function signatures
154
+ - **Shared Utilities**: Common patterns extracted to reduce duplication
155
+ - **Error Handling**: Standardized error handling across all tools
156
+ - **Response Optimization**: Task filtering and trimming for large datasets
157
+
129
158
  ## Authentication
130
159
 
131
160
  **Stdio Transport:** Requires `SUNSAMA_EMAIL` and `SUNSAMA_PASSWORD` environment variables.