can1357/oh-my-pi · error

Server "${targetServer}" returned no content for "${uri}".

Error message

Server "${targetServer}" returned no content for "${uri}".

What it means

readServerResource returned without throwing but yielded undefined — the MCP server that advertised the resource gave back no read result at all. The handler treats a missing result as a distinct failure from a thrown error, naming the specific server and URI so the misbehaving server is identifiable.

Source

Thrown at packages/coding-agent/src/internal-urls/mcp-protocol.ts:147

			await Promise.allSettled(mcpManager.getConnectedServers().map(name => mcpManager.ensureServerResources(name)));
			targetServer = resolveTargetServer(mcpManager, uri);
		}
		if (!targetServer) {
			throw new Error(
				`No MCP server has resource "${uri}".\n\nAvailable resources:\n${formatAvailableResources(mcpManager)}`,
			);
		}

		let result: MCPResourceReadResult | undefined;
		try {
			result = await mcpManager.readServerResource(targetServer, uri);
		} catch (error) {
			const message = error instanceof Error ? error.message : String(error);
			throw new Error(`MCP resource read error: ${message}`);
		}

		if (!result) {
			throw new Error(`Server "${targetServer}" returned no content for "${uri}".`);
		}

		const textParts: string[] = [];
		for (const item of result.contents) {
			if (item.text !== undefined && item.text !== null) {
				textParts.push(item.text);
			} else if (item.blob) {
				textParts.push(`[Binary content: ${item.mimeType ?? "unknown"}, base64 length ${item.blob.length}]`);
			}
		}

		const content = textParts.length > 0 ? textParts.join("\n---\n") : "(empty resource)";
		return {
			url: url.href,
			content,
			contentType: "text/plain",
			size: Buffer.byteLength(content, "utf-8"),
			notes: [`MCP server: ${targetServer}`],

View on GitHub (pinned to 9690622007)

Solutions

  1. Inspect the server's resources/read implementation and make it return { contents: [...] } (use an empty contents array for genuinely empty resources) — this is a server bug.
  2. Verify with the MCP inspector that the same URI also returns an empty read there, confirming the fault is server-side, then report/fix upstream.
  3. If the resource was removed server-side, refresh the resource list and use a currently advertised URI.
  4. On the client side, treat this message as 'server advertised but cannot serve' and fall back to re-listing resources.

Example fix

// server side — before
async readResource(uri) { /* TODO */ }
// after
async readResource(uri) {
  const text = await loadResourceText(uri);
  return { contents: [{ uri, text: text ?? "" }] };
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
  return await handler.resolve(url);
} catch (e) {
  if (e instanceof Error && /^Server ".+" returned no content/.test(e.message)) {
    const server = e.message.match(/Server "(.+)" returned/)?.[1];
    logger.warn("MCP server advertised resource but returned no result", { server, url: url.href });
    return null;
  }
  throw e;
}

Prevention

When it happens

Trigger: A server whose resources/read handler returns nothing (undefined) instead of a contents array — typically a partially implemented or buggy MCP server, or a race where the server dropped the resource after advertising it and responds with an empty/absent result.

Common situations: Custom/in-house MCP servers where resources/read is stubbed or unimplemented; servers that advertise resources via templates but return nothing for unresolvable instances; version drift where a server upgrade changed read semantics.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/63d1635589ee2586. Report an issue: GitHub.