Do NOT build anything. I want to get advice on how to build a raycast extension using React and TypeScript. I want the extension to use an LLM model of my choice (eg. claude) and connect to my own MCP server, to be able to ask questions directly in raycast and get LLM generated responses based on the MCP server. I want to use n8n and set up an AI agent where I connect an LLM + MCP server, and then use POST http request from the extension to trigger the n8n workflow, and then deliver the resopnse to the raycast extension. How can this be built, and what should I take into account?
I'll help you design a comprehensive architecture for building a Raycast extension that connects to an LLM via MCP server through n8n. Here's a detailed breakdown:
Your system will have these components:
// Use Raycast's CLI to scaffold
npm install -g @raycast/cli
raycast create my-llm-extension
Key considerations:
@raycast/api
for UI components and utilitiesYou'll need to deploy an MCP server that exposes tools/data 2. Consider:
// Example n8n HTTP Request node configuration
{
"method": "POST",
"url": "https://your-mcp-server.vercel.app/api/mcp",
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_TOKEN"
},
"body": {
"method": "tools/call",
"params": {
"name": "your_tool_name",
"arguments": "{{ $json.query }}"
}
}
}
While n8n has built-in AI nodes, for more control you might use custom function nodes with the AI SDK 3:
// Custom n8n function node
const { generateText } = require('ai');
const { anthropic } = require('@ai-sdk/anthropic');
const response = await generateText({
model: anthropic('claude-3-sonnet-20240229'),
messages: [
{ role: 'system', content: 'You are a helpful assistant with access to tools.' },
{ role: 'user', content: items[0].json.query }
],
tools: mcpToolsFromPreviousStep
});
return [{ json: { response: response.text } }];
Instead of n8n, you could use the AI SDK's MCP client directly 1, but this would require:
This architecture provides flexibility, scalability, and maintainability while leveraging each tool's strengths. The n8n layer adds powerful workflow capabilities and makes it easier to integrate multiple data sources and tools through your MCP server.
I already have an MCP server set up, and ready to connect in n8n. The only thing I need help with is building the extension, making sure I can send a http POST request from the raycast command to n8n, and being able to receive back a response from n8n agent. What's your guidance from me? I'm not an engineer, but want to build this using V0, what should I take into account, and how can I guide you best to get started? Please craft a prompt for me to give you clear instructions to help me build the extension.
Okay, I understand! You want to focus on getting the Raycast extension built with my help, and you need a clear way to give me instructions. That's a great approach, especially since you're guiding the process.
Building a Raycast extension involves writing React and TypeScript code that runs within the Raycast environment on your Mac. While I can generate this code for you, you won't be able to run or preview the Raycast extension directly within the v0 interface. You'll need to set up a Raycast development environment on your computer to use the code I provide. I can guide you on that part too when we get there.
To help me generate the best possible starting point for your Raycast extension, please use the following prompt template. Fill in the details as best as you can. The more specific you are, the better I can tailor the code to your needs.
"Hi v0, please help me build a Raycast extension. Here are the specifications:
Extension & Command Details:
User Input Interface:
I need an input field for the user to type their question.
TextField
for a single line, or TextArea
for multiple lines if questions can be long)n8n Webhook Connection:
https://your-n8n-instance.com/webhook/your-webhook-id
)Data to Send to n8n (Request Payload):
Please describe the JSON structure. For example:
{
"query": "THE_USER_S_QUESTION_WILL_GO_HERE"
}
(Specify the exact key you want to use for the user's input, e.g., "query", "prompt", "userInput")
{"Authorization": "Bearer YOUR_N8N_API_KEY"}
. For sensitive data like API keys, we should plan to use Raycast's preferences system for secure storage.)Data Expected Back from n8n (Response Payload):
Please describe the JSON structure. For example:
{
"answer": "THE_AI_S_RESPONSE_WILL_BE_HERE",
"confidence_score": 0.95,
"source_documents": ["doc1.pdf", "doc2.txt"]
}
(Specify the exact key that holds the main answer you want to display, e.g., "answer", "response", "result")
Displaying the Response in Raycast:
How should the answer from n8n be shown to the user?
<Detail>
view, which is good for longer text and supports Markdown formatting.")Basic Error Handling:
Submit Action:
Enter
in the input field also submit the query? (Usually Yes for Raycast forms)Once you provide these details, I can start generating the TypeScript and React code for your Raycast extension.
Fill out the template above, and I'll do my best to generate the initial code for your Raycast extension!
Okay, you have green light to build now, using the following prompt:
Help me build a Raycast extension. Here are the specifications:
n8n Webhook Connection:
Data to Send to n8n (Request Payload):
{
"query": "THE_USER_QUERY_WILL_GO_HERE"
}
Data Expected Back from n8n (Response Payload):
{
"answer": "THE_LMM_RESPONSE_WILL_BE_HERE",
}
Displaying the Response in Raycast:
<Detail>
viewBasic Error Handling:
Submit Action:
Enter
in the input field also submits the query