h@llo.ai -- cannot use openrouter

BTT version 6.639

My main LLM model provider is openrouter.ai. I don't know why but whenever I try to use it I get this error:

Using other tools or even curl with the same API key work fine...

are you sure the API key is correct? open router also returns that error for invalid keys

Yes, if I copy the key from BTT and paste it in a curl request, it works. Same key same model name, same API address.

I tried to use another assistant configured with a siliconflow.cn key i have, that one crashed BTT when it tried to respond. Crash attached

crash.zip (426.9 KB)

I may delete all my AI config and start from scratch, something seems very broken here...

possibly check whether the api key field contains an extra line or space (best cmd+a to select all, then delete)

I‘ll check your crashlog tomorrow!

No newlines unfortunately...

As I have both codex and opencode installed I can use those, though the response is much slower. For opencode I'm using the same openrouter key, so that key using BTT>opencode>openrouter works, but as an BTT>openai-API it fails.

Also, I tried to enable MCP servers, here is my btt-mcp-config.json:

{
	"mcpServers": {
		"bookends-mcp": {
			"command": ["/Applications/Bookends.app/Contents/MacOS/BookendsMCP/BookendsMCP"],
			"args": []
		},
		"codebase-memory-mcp": {
			"command": ["/Users/ian/.local/bin/codebase-memory-mcp"],
			"args": []
		},	
		"scrivener": {
			"command": ["/Users/ian/.pixi/bin/npx"],
			args: ["scrivener-mcp"]
		}
	}
}

In the docs it tells me I need to "activate" MCP but in skills section is missing the tools parts that the docs say I need to activate:

I suspect as I have MCP setup in opencode I don't need it in BTT, but if I can get the openai option working then I am back to no MCP servers...

OK, this may be something going wrong at the trigger-level. I have been testing using a keyboard trigger and this (my agent is called Flash)

I get the error. But I just tried this button for my agent:

...and it worked! This doesn't affect the CLI tools setup but does impact the API setup...

that is very interesting information! Possibly the link between the assistant and the trigger somehow broke (for keychain credential lookup).

Could you check whether v6.644 alpha helps with this? It adds and extra failure mode lookup

6.644 seems to have fixed this, thanks as always Andreas!

Now, how can I get my MCP servers working? :star_struck:

Currently you'd need to create a custom skill that has the mcp server tools enabled. With 6.646 (uploading) I have made it a bit easier now, you just need to enable the auto-generated skills:

I updated to 6.646, and restarted BTT. I still have my ~/Library/Application Support/BetterTouchTool/AI/btt-mcp-config.json MCP servers defined there. In the Manage skills dialog I do not see the MCP SERVERS section as in your screenshot.

I also tried to create a custom skill to try to enable them there, but the only thing related to MCP was this:

But using this custom skill and my MCP servers are still not triggering (they work in opencode / codex)...

I have added some status info in 6.651, can you check this?

I assume the JSON keys are incorrect:

{
	"mcpServers": {
		"bookends-mcp": {
			"command": ["/Applications/Bookends.app/Contents/MacOS/BookendsMCP/BookendsMCP"],
			"args": []
		},
		"codebase-memory-mcp": {
			"command": ["/Users/ian/.local/bin/codebase-memory-mcp"],
			"args": []
		},	
		"scrivener": {
			"command": ["/Users/ian/.pixi/bin/npx"],
			"args": ["scrivener-mcp"]
		}
	}
}

Maybe the command shouldn't be a list...

EDIT: right, I needed to remove the around the command values. The feedback is really helpful, thank you!!!


However, the MCP server is not working:

It returns the MCP details but never seems to run it. When it finally returns the reference it is an hallucination, I do not have that reference in my database.

Here is opencode, immediately returns the correct data via the same local MCP tool:

have you enabled the bookends-mcp for your assistant in the skills? It doesn’t look like the AI can access/activate it

Ah, OK I didn't do that sorry. Enabling them:

And running that request "use bookends-mcp to get the currently selelcted reference" -- BTT starts trying to use javascript directly (I have disable all other skills) then crashes:

bttcrash.zip (13.2 KB)

I think there was a conflict between these new MCP server permissions and the old on demand permission requests. Could you check whether it works with 6.654 ?

No more crash :saluting_face: and the prompt was answered with the correct reply.

The response was slower than when using opencode, as it seemed to use some extra javascript steps rather than using the MCP directly?:

Note I had disabled all skills apart from the MCP tools:

I realise there are a lot of moving parts here. I did strip the system prompt to just You are a fast technical problem solving agent, with access to MCP servers if necessary. but perhaps there is some other base prompt injected?

ah, in your custom prompt, did you add the {TOOL_USE_DESCRIPTION} placeholder and {BTT_TOOLS_AND_CONTEXT} placeholder? Without these the AI might not immediately know how to execute MCP in BTT.

With the next build (6.655), a stripped custom system prompt will still get the tool instructions appended automatically, so the assistant should call the MCP tool directly instead of exploring via generic JS. (The remaining speed difference vs opencode is inherent - BTT routes MCP calls through one run_javascript round-trip, so it's model-turn + JS + MCP rather than a direct MCP call, but that should not make things much slower.)

OK, if I explicitly add it it works

You are a fast technical problem solving agent, with access to MCP servers if necessary.

{TOOL_USE_DESCRIPTION}

{BTT_TOOLS_AND_CONTEXT}

If I remove them from the system prompt in 6.655 although the number of tokens sent suggests more than my prompt is being sent, I do not get a successful response. Anyway adding them to the system prompt explicitly is fine.

Could you check what the difference between the resolved prompts is in your case?

//edit: ah I think I found why it still didn't work without the placeholders. Should now be resolved in the next build.