Fix authentication method to use DEFAULT_HEADERS consistently in API calls
This commit is contained in:
18
index.ts
18
index.ts
@ -1612,23 +1612,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|||||||
|
|
||||||
case "list_projects": {
|
case "list_projects": {
|
||||||
const args = ListProjectsSchema.parse(request.params.arguments);
|
const args = ListProjectsSchema.parse(request.params.arguments);
|
||||||
const url = new URL(`${GITLAB_API_URL}/projects`);
|
const projects = await listProjects(args);
|
||||||
|
|
||||||
// Add query parameters for filtering
|
|
||||||
Object.entries(args).forEach(([key, value]) => {
|
|
||||||
if (value !== undefined) {
|
|
||||||
url.searchParams.append(key, value.toString());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await fetch(url.toString(), {
|
|
||||||
headers: DEFAULT_HEADERS,
|
|
||||||
});
|
|
||||||
|
|
||||||
await handleGitLabError(response);
|
|
||||||
const data = await response.json();
|
|
||||||
const projects = z.array(GitLabProjectSchema).parse(data);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content: [{ type: "text", text: JSON.stringify(projects, null, 2) }],
|
content: [{ type: "text", text: JSON.stringify(projects, null, 2) }],
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user