Building Custom MCP Servers for Supabase and Svelte Integration

The Model Context Protocol (MCP) has rapidly become the standard for connecting AI models to external data sources and tools. While official stores offer pre-built servers for common services, many developers find themselves needing custom solutions for specific frameworks like Svelte or niche database configurations. This guide addresses the common scenario where an agent successfully calls tools from the official store but ignores locally running custom servers, leaving your workflow incomplete. It is important to note that while this guide discusses AI integration patterns often associated with Claude, this site is not affiliated with Anthropic, and the tools described work with any MCP-compatible client.
A frequent pain point involves the discrepancy between how different agents handle local MCP servers. You might find that while one tool works seamlessly via the inbuilt store, a custom server running on your local machine is completely ignored by the agent, even though other coding assistants like GitHub Copilot handle it without issue. This often stems from configuration nuances rather than fundamental protocol errors. Understanding these mechanics is crucial for anyone looking to extend their AI coding capabilities beyond standard library functions.
We will walk through the process of setting up, configuring, and debugging custom MCP servers. You will learn how to ensure your local tools are discoverable and callable by your preferred AI agent, whether you are using Supabase for backend data or Svelte for frontend component generation. By the end of this article, you will have a robust local MCP server that integrates seamlessly into your development environment, allowing your AI assistant to access the specific tools it needs to be truly productive.
Frequently asked questions
What is the Model Context Protocol (MCP)?
MCP is an open protocol that standardizes how applications provide context to Large Language Models. It defines a machine-readable format for tools, resources, and prompts, allowing AI agents to interact with external services consistently. By using MCP, developers can create reusable server components that any compatible client can utilize without custom integration code.
How does a custom MCP server differ from a standard tool call?
A standard tool call is often hard-coded into a specific model's interface. In contrast, a custom MCP server exposes a standard interface that any MCP-compatible client can discover and invoke. This decouples the tool logic from the AI model, allowing you to update your tools independently of your agent's version. It also enables sharing tools across different applications.
Why is my local MCP server ignored by the agent?
This usually happens because the agent cannot discover the server's capabilities. Ensure the server is running and the client is configured to connect to the correct endpoint. Sometimes, the server fails to announce its tools during the initialization handshake. Check the server logs for errors and verify that the client configuration explicitly includes the local server in its list of enabled tools.
Which is better: using the official store or a custom server?
The official store is better for widely used services like GitHub or Slack, where maintenance is handled by the community. Custom servers are superior for proprietary data, specific framework integrations like Svelte, or when you need precise control over tool behavior. Use the store for common utilities and custom servers for unique workflow requirements.
How do I debug a failing MCP server connection?
Start by checking the server logs for startup errors. Verify that the server is listening on the expected port and that the client configuration points to the correct address. Use verbose logging in your client to see the handshake process. If the server starts but tools are missing, ensure the tool definitions are correctly formatted and returned during the initialization phase.
Can I use MCP servers with any AI model?
MCP is model-agnostic, meaning any client that implements the protocol can use the servers. However, the model itself must be capable of understanding and invoking the tools based on their descriptions. Most modern LLMs support MCP, but you may need to adjust your prompt or system instructions to ensure the model prioritizes tool usage effectively.
What are the security risks of running a local MCP server?
Local servers expose your local file system or database to the AI agent. Ensure the server runs with minimal permissions, exposing only the necessary files or endpoints. Be cautious with tools that can modify or delete data. Always review the tool definitions to understand what actions the agent can perform, and consider using read-only modes for sensitive operations.
How do I share my custom MCP server with others?
You can package your server as a standard npm or pip package and distribute it via your preferred registry. Alternatively, you can publish it to the official MCP store if it fits the community guidelines. Provide clear documentation on how to install and configure the server, including any required environment variables or dependencies, to ensure a smooth onboarding experience for other users.
- Understanding MCP Architecture and Server Roles
- Setting Up a Local MCP Server for Svelte
- Configuring Supabase MCP Server
- Integrating MCP Servers with AI Agents
- Debugging Common MCP Server Issues
- Advanced MCP Server Patterns
- Production Considerations for MCP Servers
- Comparing MCP with Other Integration Methods
Step by step
- Initialize MCP Server — Create a new project and install the MCP SDK. Define your tools with clear names and schemas, ensuring the server announces them during initialization.
- Configure Client — Edit your AI client's configuration file to include the local server's endpoint. Ensure the transport mechanism matches your server's setup.
- Test Tool Discovery — Start the server and client, using verbose logging to verify that the tools are correctly discovered and available to the AI agent.
- Debug and Iterate — Test the tools with the AI agent, checking for errors in the logs. Adjust tool definitions and configurations as needed to improve performance and reliability.
Understanding MCP Architecture and Server Roles
The Model Context Protocol operates on a client-server architecture where the client, typically your AI agent, requests capabilities from the server. The server responds with a list of available tools, resources, and prompts. This discovery phase is critical; if the server fails to announce its tools correctly, the agent will not know they exist, leading to the "ignored server" phenomenon many developers encounter. This is often due to a mismatch in the protocol version or a failure in the capability declaration.
In this setup, the server acts as a bridge between the AI model and your local environment or external APIs. It handles the execution logic, data fetching, and formatting, returning results in a standardized JSON format. This abstraction allows the AI model to focus on reasoning and decision-making without worrying about the underlying implementation details of each tool. You can find more details on how to monitor your API usage effectively in our guide on Monitoring Your Claude API Usage Effectively.
The Initialization Handshake
During initialization, the client sends an initialize request, and the server responds with its capabilities. This is where the tool list is generated. If your custom server uses a non-standard framework or has a bug in its capability declaration, the client may assume it has no tools and skip it entirely. Ensure your server explicitly lists all tools during this phase.
Tool Definition Structure
Each tool must have a name, description, and input schema. The description is crucial for the AI model to understand when to use the tool. A vague description often leads to the model ignoring the tool, even if it is correctly registered. Be specific about what the tool does, its inputs, and its outputs to improve discoverability and usage accuracy.
Setting Up a Local MCP Server for Svelte
Creating a custom MCP server for Svelte involves defining tools that can generate components, manage state, or analyze code. You can use Node.js and the MCP SDK to build this server. Start by initializing a new project and installing the necessary dependencies. Define your tools using the SDK's tool definition interface, ensuring each tool has a clear name and schema.
For Svelte-specific tools, you might create a tool that generates a component skeleton based on a description or one that analyzes the current project structure. Implement the logic to read files from your local directory or interact with the Svelte compiler. Ensure the server listens on a local port, typically 3000 or 8080, and is accessible by your client. This local setup allows you to iterate quickly on your tools without deploying to a remote server.
Defining Svelte Tools
Create tools that reflect the Svelte developer workflow. For example, a "create-component" tool that takes a name and type as input and returns the generated code. Another tool could be "analyze-svelte", which takes a code snippet and returns suggestions for optimization. These tools should be designed to be composable, allowing the AI to chain them for complex tasks.
Handling File Operations
Your server needs permission to read and write files in your Svelte project directory. Use the file system API to read component files and update them as needed. Ensure you handle errors gracefully, such as when a file is locked or a directory does not exist. Log these errors to help with debugging when the agent fails to perform a file operation.
- Use the MCP SDK to define tools with clear schemas.
- Implement logic for file reading and writing.
- Ensure the server listens on a local port.
const { McpServer } = require('@modelcontextprotocol/sdk/server/mcp.js');
const server = new McpServer({ name: 'svelte-mcp', version: '1.0.0' });
server.tool('create-component', 'Generates a Svelte component', { name: { type: 'string' }, type: { type: 'string' } }, async ({ name, type }) => {
const code = `<script>\n// Component: ${name}\n</script>\n<h1>${name}</h1>`;
return { content: [{ type: 'text', text: code }] };
});
server.start();
Configuring Supabase MCP Server
Supabase provides a robust set of tools for database management, authentication, and storage. The official Supabase MCP server is available in the store, but you might need to configure it to work with your specific project. This involves setting environment variables for your project URL and API key, ensuring the server can authenticate with Supabase's backend.
Once configured, the server exposes tools for querying tables, inserting data, and managing users. These tools are essential for AI agents that need to interact with your database dynamically. Ensure your Supabase project has the necessary row-level security policies in place to prevent unauthorized data access by the AI agent. You can also check out our article on Running MCP Servers in Production for best practices on scaling these setups.
Environment Configuration
Set the SUPABASE_URL and SUPABASE_ANON_KEY environment variables before starting your server. These credentials allow the MCP server to authenticate with Supabase. You can find these values in your Supabase dashboard under Project Settings > API. Ensure the key has the necessary permissions to perform the actions your tools require.
Tool Discovery
Verify that the Supabase MCP server correctly announces its tools. Use a client that supports verbose logging to see the list of available tools. If tools are missing, check the server logs for authentication errors. Ensure the server can reach the Supabase API and that your project is active and accessible.
Integrating MCP Servers with AI Agents
Integrating your custom MCP servers with your AI agent requires configuring the client to recognize and use the local server. This often involves editing the client's configuration file to include the server's endpoint. For example, in VSCode or other IDEs, you might need to add a section to your settings.json file that points to your local MCP server.
Ensure the client is set to use the correct transport mechanism, typically SSE or stdio. SSE is useful for long-running servers, while stdio is better for short-lived processes. Choose the transport that best fits your workflow and server architecture. Misconfiguration here is a common cause of the "ignored server" issue. For more on handling limits, see How to Handle Claude API Rate Limits.
Client Configuration
Edit your client's configuration file to include the local server. For example, add a section that specifies the server's URL or path. Ensure the client is set to enable tool usage for this server. Some clients require explicit permission to use tools from local servers, so check the settings for any toggle switches.
Transport Mechanisms
SSE (Server-Sent Events) is ideal for servers that need to maintain a persistent connection, such as those monitoring file changes. Stdio is simpler and works well for tools that execute quickly and return results immediately. Choose the transport that matches your server's lifecycle and the client's capabilities.

Debugging Common MCP Server Issues
Debugging MCP servers often involves checking the server logs for errors during startup or tool execution. If the server starts but the client doesn't see the tools, the issue is likely in the capability declaration or the handshake process. Use verbose logging to see the exact messages exchanged between the client and server.
Another common issue is network connectivity. If the server is running on a different port or interface, ensure the client can reach it. Firewalls or security software might block the connection. Test the server's endpoint manually using a tool like curl or Postman to verify it is responding correctly. This step is crucial for diagnosing why a server might be ignored by the agent.
Checking Server Logs
Review the server logs for any errors during initialization or tool invocation. Look for messages indicating failed tool definitions or connection errors. Many MCP servers output detailed logs when run in debug mode, which can help identify the root cause of issues. Redirect the logs to a file for easier analysis.
Verifying Network Connectivity
Use curl or Postman to test the server's endpoint. If the server uses SSE, ensure the client can establish a persistent connection. If the server uses stdio, verify that the client can launch the server process correctly. Network issues are a frequent cause of servers being ignored, so ensure the client and server are on the same network.
- Enable verbose logging in the server and client.
- Test the server endpoint manually using curl.
- Check firewall settings and network configurations.
Advanced MCP Server Patterns
Advanced MCP servers can include resources, which are static or dynamic data sources that the AI can read. Resources complement tools by providing context that doesn't require a specific action. For example, a resource could provide the current documentation for a library, allowing the AI to reference it during code generation.
You can also implement prompts, which are pre-defined sequences of instructions for the AI. Prompts can simplify complex workflows by providing a structured way to interact with the server. For example, a prompt could ask the AI to analyze a codebase and generate a summary, using the server's tools to gather the necessary information. This pattern is useful for creating reusable workflows.
Implementing Resources
Define resources that the AI can read to gain context. These could be files, API endpoints, or database queries. Ensure the resources are accessible and formatted correctly. Resources are particularly useful for providing large amounts of data that the AI needs to reference but doesn't need to modify.
Creating Prompts
Define prompts that guide the AI through specific workflows. A prompt can combine multiple tools and resources to perform a complex task. For example, a "code-review" prompt could use tools to analyze the code and resources to fetch the latest style guide. Prompts make it easier for the AI to perform multi-step tasks.

Production Considerations for MCP Servers
When running MCP servers in production, consider scalability, security, and monitoring. A single server might not handle high load, so consider using load balancers or multiple server instances. Ensure your server can handle concurrent requests efficiently, especially if you are using it with multiple AI agents simultaneously. You can also track your quotas with onWatch CLI to stay within limits.
Security is crucial, especially if your server exposes sensitive data or commands. Use authentication and authorization to restrict access. Monitor your server's performance using metrics like request latency and error rates. This data can help you identify bottlenecks and optimize your server for better performance. Consider using a container orchestration system for advanced scaling.
Scalability Strategies
Use load balancers to distribute requests across multiple server instances. Ensure your server is stateless where possible, allowing easy scaling. Monitor resource usage like CPU and memory to ensure your server can handle the load. Consider using a container orchestration system like Kubernetes for advanced scaling.
Monitoring and Logging
Implement logging to track server performance and errors. Use metrics to monitor request latency, error rates, and tool usage. This data can help you optimize your server and identify issues before they impact users. Consider using a monitoring tool like Prometheus or Grafana for real-time insights.
Comparing MCP with Other Integration Methods
MCP offers a standardized way to connect AI models to tools, but it is not the only option. Other methods include direct API calls, webhooks, and custom integrations. Each method has its pros and cons, and the best choice depends on your specific needs. MCP is ideal for reusable, shareable tools, while direct API calls might be better for simple, one-off integrations.
Webhooks are useful for event-driven architectures, where the server notifies the client of changes. Custom integrations offer maximum flexibility but require more development effort. MCP strikes a balance between flexibility and standardization, making it a popular choice for AI coding assistants. For more on comparing models, see our guide on Sonnet vs Opus: Which Is Better for Code?.
Direct API Calls
Direct API calls are simple and straightforward but lack the reusability and standardization of MCP. They are best for simple integrations where the tool logic is tightly coupled with the AI model. MCP provides a cleaner separation of concerns, making it easier to update tools without changing the client.
Webhooks vs MCP
Webhooks are event-driven, notifying the client of changes, while MCP is request-driven, where the client asks for data. Use webhooks for real-time updates and MCP for on-demand tool execution. Both can be used together, with MCP handling tool execution and webhooks providing real-time notifications.
- MCP offers standardization and reusability.
- Direct API calls are simpler but less flexible.
- Webhooks are best for event-driven architectures.

Test Claude's capabilities with your own prompts using a free key, no credit card required.