diff options
| author | haoyuren <13851610112@163.com> | 2026-03-15 20:52:13 -0500 |
|---|---|---|
| committer | haoyuren <13851610112@163.com> | 2026-03-15 20:52:13 -0500 |
| commit | 66a403488f3a7bc32a02bc9933c396dc4c4e031d (patch) | |
| tree | af52777ac10a1b31487203c4281178e9188c27ba /src/mcp/lattex.mjs | |
| parent | 6d4ee5ccd5529d6d2764da73e73fac57d7bfb216 (diff) | |
Add API key management UI and wire S2 key to MCP
- Settings modal on project list page for OpenAI, Anthropic, OpenRouter, Gemini, Semantic Scholar keys
- Keys stored in userData/api-keys.json, masked by default with show/hide toggle
- S2 API key passed to MCP server via .lattex-mcp.json to avoid rate limits
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'src/mcp/lattex.mjs')
| -rw-r--r-- | src/mcp/lattex.mjs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/mcp/lattex.mjs b/src/mcp/lattex.mjs index 65f6d87..64520f7 100644 --- a/src/mcp/lattex.mjs +++ b/src/mcp/lattex.mjs @@ -528,6 +528,13 @@ const TOOLS = [ // ── Semantic Scholar helpers ───────────────────────────────── +function getSemanticScholarApiKey() { + try { + const state = readState() + return state.semanticScholarApiKey || null + } catch { return null } +} + function semanticScholarSearch(query, limit) { return new Promise((resolve) => { const params = new URLSearchParams({ @@ -535,13 +542,14 @@ function semanticScholarSearch(query, limit) { limit: String(limit), fields: 'title,authors,year,externalIds,venue,publicationDate,abstract,citationCount' }) + const headers = { 'User-Agent': 'LatteX-MCP/1.0' } + const apiKey = getSemanticScholarApiKey() + if (apiKey) headers['x-api-key'] = apiKey const options = { hostname: 'api.semanticscholar.org', path: `/graph/v1/paper/search?${params}`, method: 'GET', - headers: { - 'User-Agent': 'LatteX-MCP/1.0' - } + headers } const req = https.request(options, (res) => { |
