@openviking/opencode-plugin 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -201,11 +201,14 @@ export function createOpenVikingMcpProxy({
201
201
  return true;
202
202
  }
203
203
 
204
- function headersForRequest(includeSession = true, message = null) {
204
+ function headersForRequest(includeSession = true) {
205
205
  const headers = {
206
206
  "Content-Type": "application/json",
207
207
  "Accept": "application/json, text/event-stream",
208
- "MCP-Protocol-Version": message?.params?.protocolVersion || protocolVersion,
208
+ // Always the proxy's current version (default, then server-negotiated) —
209
+ // never the client's un-negotiated ask, which strict upstreams reject
210
+ // with HTTP 400 before initialize negotiation can run.
211
+ "MCP-Protocol-Version": protocolVersion,
209
212
  };
210
213
  if (includeSession && sessionId) headers["Mcp-Session-Id"] = sessionId;
211
214
  if (proxyConfig.apiKey) headers.Authorization = `Bearer ${proxyConfig.apiKey}`;
@@ -265,7 +268,7 @@ export function createOpenVikingMcpProxy({
265
268
  try {
266
269
  const res = await fetchImpl(proxyConfig.mcpUrl, {
267
270
  method: "POST",
268
- headers: headersForRequest(includeSession, message),
271
+ headers: headersForRequest(includeSession),
269
272
  body: JSON.stringify(message),
270
273
  signal: controller.signal,
271
274
  });
@@ -273,6 +276,10 @@ export function createOpenVikingMcpProxy({
273
276
  const messages = parseHttpBody(res.headers.get("content-type"), text);
274
277
  const nextSessionId = res.headers.get("mcp-session-id");
275
278
  if (nextSessionId) sessionId = nextSessionId;
279
+ if (message?.method === "initialize" && res.ok) {
280
+ const negotiated = messages.find((m) => typeof m?.result?.protocolVersion === "string")?.result.protocolVersion;
281
+ if (negotiated) protocolVersion = negotiated;
282
+ }
276
283
  if (!res.ok) {
277
284
  throw new HttpStatusError(res.status, res.statusText, text, messages);
278
285
  }
@@ -366,7 +373,7 @@ export function createOpenVikingMcpProxy({
366
373
  const expectsResponse = isRequest(message);
367
374
  if (message.method === "initialize") {
368
375
  initializeRequest = cloneMessage(message);
369
- protocolVersion = message.params?.protocolVersion || protocolVersion || DEFAULT_PROTOCOL_VERSION;
376
+ protocolVersion = DEFAULT_PROTOCOL_VERSION;
370
377
  sessionId = "";
371
378
  }
372
379
  if (message.method === "notifications/initialized") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openviking/opencode-plugin",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "author": "@openviking",
5
5
  "description": "Unified OpenCode plugin for OpenViking repository retrieval and long-term memory",
6
6
  "type": "module",