projoflow-mcp-server 1.1.3 → 1.1.5

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.
Files changed (2) hide show
  1. package/index.js +42 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -68,11 +68,37 @@ async function authenticate() {
68
68
 
69
69
  // For client tokens, fetch accessible project IDs
70
70
  if (authContext.token_type === 'client' && authContext.client_id) {
71
- const { data: projectIds } = await supabase.rpc('get_client_project_ids', {
71
+ console.error(`Fetching projects for client ${authContext.client_id}...`);
72
+ const { data: projectIds, error: projectError } = await supabase.rpc('get_client_project_ids', {
72
73
  p_user_id: authContext.user_id,
73
74
  p_client_id: authContext.client_id
74
75
  });
75
- authContext.accessible_project_ids = projectIds || [];
76
+
77
+ if (projectError) {
78
+ console.error(`Error fetching projects: ${projectError.message}`);
79
+ }
80
+ console.error(`Raw projectIds response: ${JSON.stringify(projectIds)}`);
81
+
82
+ // Handle different return formats from Supabase RPC:
83
+ // - Direct array: ["uuid1", "uuid2"]
84
+ // - Wrapped: [{"get_client_project_ids": ["uuid1"]}]
85
+ // - Single value: "uuid1"
86
+ // - Null: null
87
+ let parsedProjectIds = [];
88
+ if (Array.isArray(projectIds)) {
89
+ if (projectIds.length > 0 && typeof projectIds[0] === 'object' && projectIds[0].get_client_project_ids) {
90
+ // Wrapped format from SQL query
91
+ parsedProjectIds = projectIds[0].get_client_project_ids || [];
92
+ } else {
93
+ // Direct array format
94
+ parsedProjectIds = projectIds;
95
+ }
96
+ } else if (typeof projectIds === 'string') {
97
+ parsedProjectIds = [projectIds];
98
+ }
99
+
100
+ authContext.accessible_project_ids = parsedProjectIds;
101
+ console.error(`Parsed project IDs: ${JSON.stringify(parsedProjectIds)}`);
76
102
  console.error(`Authenticated as CLIENT via API key (${authContext.accessible_project_ids.length} projects accessible)`);
77
103
  } else {
78
104
  console.error(`Authenticated via API key for workspace ${authContext.workspace_id}`);
@@ -104,7 +130,20 @@ async function authenticate() {
104
130
  p_user_id: authContext.user_id,
105
131
  p_client_id: authContext.client_id
106
132
  });
107
- authContext.accessible_project_ids = projectIds || [];
133
+
134
+ // Handle different return formats (same as above)
135
+ let parsedProjectIds = [];
136
+ if (Array.isArray(projectIds)) {
137
+ if (projectIds.length > 0 && typeof projectIds[0] === 'object' && projectIds[0].get_client_project_ids) {
138
+ parsedProjectIds = projectIds[0].get_client_project_ids || [];
139
+ } else {
140
+ parsedProjectIds = projectIds;
141
+ }
142
+ } else if (typeof projectIds === 'string') {
143
+ parsedProjectIds = [projectIds];
144
+ }
145
+
146
+ authContext.accessible_project_ids = parsedProjectIds;
108
147
  console.error(`Authenticated as CLIENT via API key (${authContext.accessible_project_ids.length} projects accessible)`);
109
148
  } else {
110
149
  // Update last_used_at
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "projoflow-mcp-server",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "description": "MCP server for ProjoFlow project management - connect AI tools to your projects",
5
5
  "main": "index.js",
6
6
  "type": "module",