Skip to main content
Glama

AFFiNE MCP Server

by DAWNCR0W
config.ts2.06 kB
import { EndpointMap } from "./types.js"; export type ServerConfig = { baseUrl: string; apiToken?: string; cookie?: string; headers?: Record<string, string>; graphqlPath: string; email?: string; password?: string; defaultWorkspaceId?: string; endpoints: EndpointMap; }; const defaultEndpoints: EndpointMap = { listWorkspaces: { method: "GET", path: "/api/workspaces" }, listDocs: { method: "GET", path: "/api/workspaces/:workspaceId/docs" }, getDoc: { method: "GET", path: "/api/docs/:docId" }, createDoc: { method: "POST", path: "/api/workspaces/:workspaceId/docs" }, updateDoc: { method: "PATCH", path: "/api/docs/:docId" }, deleteDoc: { method: "DELETE", path: "/api/docs/:docId" }, searchDocs: { method: "GET", path: "/api/workspaces/:workspaceId/search" } }; export function loadConfig(): ServerConfig { const baseUrl = process.env.AFFINE_BASE_URL?.replace(/\/$/, "") || "http://localhost:3010"; const apiToken = process.env.AFFINE_API_TOKEN; const cookie = process.env.AFFINE_COOKIE; const email = process.env.AFFINE_EMAIL; const password = process.env.AFFINE_PASSWORD; let headers: Record<string, string> | undefined = undefined; const headersJson = process.env.AFFINE_HEADERS_JSON; if (headersJson) { try { headers = JSON.parse(headersJson); } catch (e) { console.warn("Failed to parse AFFINE_HEADERS_JSON; ignoring."); } } if (cookie) { headers = { ...(headers || {}), Cookie: cookie }; } const graphqlPath = process.env.AFFINE_GRAPHQL_PATH || "/graphql"; const defaultWorkspaceId = process.env.AFFINE_WORKSPACE_ID; let endpoints = defaultEndpoints; const endpointsJson = process.env.AFFINE_ENDPOINTS_JSON; if (endpointsJson) { try { endpoints = { ...defaultEndpoints, ...JSON.parse(endpointsJson) } as EndpointMap; } catch (e) { console.warn("Failed to parse AFFINE_ENDPOINTS_JSON; using defaults."); } } return { baseUrl, apiToken, cookie, headers, graphqlPath, email, password, defaultWorkspaceId, endpoints }; }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/DAWNCR0W/affine-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server