@apideck/docs-mcp
Version:
MCP server that lets agents search and retrieve your documentation at query time instead of relying on stale training data.
32 lines • 1.18 kB
JavaScript
// SPDX-License-Identifier: MIT
/**
* Vercel function: /mcp (rewritten from /api/mcp). Configuration comes from
* DOCS_DIR, DOCS_BASE_URL, DOCS_ABOUT and DOCS_NAME. The index is built once
* per function instance and reused across requests.
*/
import { createStore, resolveConfig } from '../src/config.js';
import { createHttpHandler } from '../src/http.js';
export const config = { maxDuration: 60 };
let cachedStore = null;
const loadCachedStore = () => {
if (!cachedStore) {
const store = createStore(resolveConfig());
cachedStore = store.load().then(() => store);
cachedStore.catch(() => {
cachedStore = null;
});
}
return cachedStore;
};
export const createHandler = (opts = {}) => {
const cfg = resolveConfig();
return createHttpHandler({
store: opts.store ?? loadCachedStore,
name: cfg.name,
...(cfg.about !== undefined ? { about: cfg.about } : {}),
version: process.env['npm_package_version'] ?? '0.1.0',
info: { endpoint: '/mcp', commit_sha: process.env['VERCEL_GIT_COMMIT_SHA'] ?? null },
});
};
export default createHandler({});
//# sourceMappingURL=mcp.js.map