Skip to content

Commit 12352b4

Browse files
committed
feat: add user-agent header
1 parent 8ae4e76 commit 12352b4

File tree

4 files changed

+7
-0
lines changed

4 files changed

+7
-0
lines changed

src/DashboardApi.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type { Acl } from "algoliasearch";
88
export type DashboardApiOptions = {
99
baseUrl: string;
1010
appState: AppStateManager;
11+
userAgent: string;
1112
};
1213

1314
const User = z.object({
@@ -197,6 +198,7 @@ export class DashboardApi {
197198
Authorization: `Bearer ${this.#options.appState.get("accessToken")}`,
198199
"Content-Type": "application/json",
199200
Accept: "application/vnd.api+json",
201+
"User-Agent": "algolia-mcp-node/0.0.2",
200202
};
201203
}
202204
}

src/commands/start-server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export async function startServer(opts: StartServerOptions) {
4444

4545
const dashboardApi = new DashboardApi({
4646
baseUrl: CONFIG.dashboardApiBaseUrl,
47+
userAgent: CONFIG.userAgent,
4748
appState,
4849
});
4950

src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ export const CONFIG = {
99
tokenUrl: `https://dashboard.algolia.com/oauth/token`,
1010
// Dashboard API
1111
dashboardApiBaseUrl: "https://api.dashboard.algolia.com",
12+
userAgent: "algolia-mcp-node/0.0.2",
1213
};

src/tools/registerOpenApi.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { type DashboardApi } from "../DashboardApi.ts";
44
import { jsonSchemaToZod } from "../helpers.ts";
55
import { isToolAllowed, type ToolFilter } from "../toolFilters.ts";
66
import type { Methods, OpenApiSpec, Operation, SecurityScheme } from "../openApi.ts";
7+
import { CONFIG } from "../config.ts";
78

89
export type RequestMiddleware = (opts: {
910
request: Request;
@@ -184,6 +185,8 @@ function buildToolCallback({
184185
}
185186
}
186187

188+
request.headers.set("User-Agent", CONFIG.userAgent);
189+
187190
if (requestMiddlewares?.length) {
188191
for (const middleware of requestMiddlewares) {
189192
request = await middleware({ request, params });

0 commit comments

Comments
 (0)