How 3mdistal/css-mcp-server works
Project Type & Purpose
• This is a Node.js/TypeScript-based MCP (Model Context Protocol) server acting as a “CSS Tutor.”
• Its purpose is to provide an AI client (e.g., Claude desktop or Cursor) with personalized CSS feature updates through defined resources, tools, and prompts.
• Key MCP concepts demonstrated include: defining a persistent Resource (CSS knowledge store), multiple Tools (to fetch CSS updates and manage memory), and a static Prompt for guiding user interactions.
Analyzing the File Structure
• Top-Level Files: .env.example, .gitignore, README.md, package.json, tsconfig.json.
• Data Directory: Contains “data/memory.json” which serves as the persistent store for the CSS knowledge resource.
• src Directory: Contains the source code for the server.
• src/index.ts: Main server entry point that initializes and connects everything.
• src/prompts: Contains the definition of prompts (e.g., the “css-tutor-guidance” embedded in the code).
• src/resources: Contains the resource definition (CSS knowledge memory with read/write operations defined along with Zod validations).
• src/tools: Contains definitions of server tools (e.g., get_latest_updates, read_from_memory, write_to_memory).
• This modular organization suggests an architecture that separates concerns: core server initialization, resource management, tool functionality, and client guidance through prompts.
Key System Components
a. MCP Server Core:
• Entry point from “src/index.ts”: Initializes the MCP server using @modelcontextprotocol/sdk.
• It wires together prompts, resources, and tools by calling registration functions from their respective modules.
b. Resources:
• “css_knowledge_memory” (defined in src/resources/index.ts): Represents persistent state stored in data/memory.json.
• That this component handles JSON file I/O, including reading validation (using Zod) and writing back updates.
c. Tools:
• Three primary tools:
• get_latest_updates – Calls an external API (OpenRouter/Perplexity) to fetch CSS updates.
• read_from_memory – Reads from “css_knowledge_memory.”
• write_to_memory – Updates the memory file.
• These tools are linked to the server via registration in src/tools/index.ts.
d. Prompt:
• A static CSS tutor guidance prompt (defined in src/prompts/index.ts).
• It provides a set of instructions/workflow for the AI client on how to interact with the tools (e.g., order of operations, decision flow).
e. Client Interface/Transport:
• The server uses StdioServerTransport (from the SDK) for handling communication over standard input/output. This channel is critical as it forms the bridge between the AI client (e.g., Claude or Cursor) and the server.
f. External Dependencies:
• Node.js, TypeScript, and several libraries (zod, node-fetch, dotenv).
• Configuration (.env, package.json) and build process (tsconfig.json).
Additional Elements
• Notes about environmental configurations (e.g., use of .env for API keys) and debugging instructions using the MCP Inspector.
• Build flow steps where applicable (compilation via tsc, use of package.json build scripts).
• The core MCP server with its modular components (prompts, tools, resources)
• The interaction pathways between these components and the external entities (AI clients and API services)
• Clear, directional flow of data (user queries and responses, resource updates, API calls).