← All posts

How to Connect Your Own Project to AI Assistants with MCP

AM

Ahmad Mkhlalati

October 23, 2026 · 4 min read

The Model Context Protocol (MCP) lets an AI assistant such as Claude use your project directly: read its data, call its API and take actions on your behalf. This guide walks through connecting an existing project, step by step. 1. The idea in one paragraph You don't give the AI access to your database or code. Instead, you write a small MCP server that sits next to your project and exposes a few "tools", for example "list_orders" or "create_post". Each tool is a normal function that calls your project's API. The assistant sees the list of tools, decides when to use them, and the server does the real work. 2. What you need - A project with an API (REST, GraphQL or even direct functions you can call). - Node.js 18+ (or Python 3.10+ if you prefer the Python SDK). - An MCP client: Claude Desktop, Claude Code, or a claude.ai custom connector. - A way to authenticate, ideally a personal API token per user. 3. Create the MCP server Start a new folder and install the official SDK: npm init -y npm install @modelcontextprotocol/sdk zod Then create server.js (set "type": "module" in package.json): import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; import { z } from "zod"; const API_URL = process.env.API_URL; const API_TOKEN = process.env.API_TOKEN; async function api(path, options = {}) { const res = await fetch(API_URL + path, { ...options, headers: { "Content-Type": "application/json", Authorization: "Bearer " + API_TOKEN, ...options.headers, }, }); if (!res.ok) throw new Error(res.status + " " + (await res.text())); return res.json(); } const server = new McpServer({ name: "my-project", version: "1.0.0" }); server.registerTool( "list_posts", { description: "List all blog posts, newest first." }, async () => { const posts = await api("/api/posts"); return { content: [{ type: "text", text: JSON.stringify(posts, null, 2) }] }; } ); server.registerTool( "create_post", { description: "Publish a new post as the authenticated user.", inputSchema: { title: z.string().min(1), content: z.string().min(1) }, }, async ({ title, content }) => { const post = await api("/api/posts", { method: "POST", body: JSON.stringify({ title, content }), }); return { content: [{ type: "text", text: JSON.stringify(post, null, 2) }] }; } ); await server.connect(new StdioServerTransport()); That's a complete MCP server. Each tool has a name, a clear description (the AI reads this to decide when to use it) and an input schema that validates arguments before your code runs. 4. Add authentication to your project The safest pattern is a personal API token: - Add a page in your app where a signed-in user can create a token. - Store only a hash of the token in the database, and show the raw value once. - In your API, read the "Authorization: Bearer ..." header, hash it, and look up the user. - Every request from the MCP server then runs as that user, with that user's permissions. - Let users revoke tokens at any time. Never hard-code tokens in the server file. Pass them in as environment variables. 5. Test it with the MCP Inspector Before connecting a real assistant, try your tools in the official inspector: npx @modelcontextprotocol/inspector node server.js It opens a page in your browser where you can list the tools, fill in arguments and see exactly what comes back. 6. Connect it to Claude Desktop Open Settings > Developer > Edit Config, which opens claude_desktop_config.json, and add: { "mcpServers": { "my-project": { "command": "node", "args": ["C:/path/to/server.js"], "env": { "API_URL": "https://your-project.com", "API_TOKEN": "your-personal-token" } } } } Restart Claude Desktop. Your tools now appear in the tools menu, and you can simply ask: "List my latest posts" or "Publish a post about...". 7. Connect it to Claude Code From a terminal, register the same server once: claude mcp add my-project --env API_URL=https://your-project.com --env API_TOKEN=your-token -- node C:/path/to/server.js Run "claude mcp list" to check it's connected. Now Claude Code can use your project while you work on it, for example to check real data while debugging. 8. Going remote: one server for everyone A local stdio server is perfect for yourself. To share it with a team, run the server over HTTP instead (the SDK includes a Streamable HTTP transport), host it next to your project, and protect it with OAuth or per-user tokens. Users can then add it as a custom connector in claude.ai by pasting its URL, with nothing to install. This blog is connected exactly this way, and this post was published through it. 9. Tips for good tools - Start small: one or two read-only tools first, then add write actions. - Write clear descriptions. The AI chooses tools based on them. - Keep tools focused. "get_order_status" is better than a generic "run_query". - Validate every input and return helpful error messages. - Enforce permissions in your API, not in the MCP server. The server should never be able to do more than the user could do themselves. - Log tool calls so you can see what the assistant did. Conclusion Connecting your project through MCP takes an afternoon: a small server, a few well-described tools and a token-based login. Once it's done, every MCP-compatible assistant can work with your real data, safely and under your rules. Questions about connecting your own project? Leave a comment below.

Conversation (0)

No comments yet. Start the conversation.

    Log in to join the conversation.