diff --git a/.husky/pre-commit b/.husky/pre-commit index 2e67158..6e1eeed 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,2 +1,5 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + npx lint-staged npm run build diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..33ed963 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +# Generated by https://smithery.ai. See: https://smithery.ai/docs/config#dockerfile +FROM node:lts-alpine + +# Create app directory +WORKDIR /app + +# Copy package.json and package-lock.json +COPY package*.json ./ + +# Install dependencies, ignoring any prepare scripts +RUN npm install --ignore-scripts + +# Copy the rest of the application code +COPY . . + +# Build the application +RUN npm run build + +ENV LEETCODE_SITE=global \ + LEETCODE_SESSION= + +# Expose any port if needed (MCP uses stdio, so not required for now) + +# Set the default command +CMD node build/index.js \ + --site ${LEETCODE_SITE:-global} \ + --session ${LEETCODE_SESSION} diff --git a/README.md b/README.md index 8239fb7..b1147a7 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![NPM Version](https://img.shields.io/npm/v/@jinzcdev/leetcode-mcp-server.svg)](https://www.npmjs.com/package/@jinzcdev/leetcode-mcp-server) [![GitHub License](https://img.shields.io/github/license/jinzcdev/leetcode-mcp-server.svg)](https://img.shields.io/github/license/jinzcdev/leetcode-mcp-server.svg) [![Stars](https://img.shields.io/github/stars/jinzcdev/leetcode-mcp-server)](https://github.com/jinzcdev/leetcode-mcp-server) +[![smithery badge](https://smithery.ai/badge/@jinzcdev/leetcode-mcp-server)](https://smithery.ai/server/@jinzcdev/leetcode-mcp-server) The LeetCode MCP Server is a [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction) server that provides seamless integration with LeetCode APIs, enabling advanced automation and intelligent interaction with LeetCode's programming problems, contests, solutions, and user data. @@ -21,6 +22,16 @@ The LeetCode MCP Server is a [Model Context Protocol (MCP)](https://modelcontext ## Installation +### Installing via Smithery + +To install leetcode-mcp-server for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@jinzcdev/leetcode-mcp-server): + +```bash +npx -y @smithery/cli install @jinzcdev/leetcode-mcp-server --client claude +``` + +### Manual Installation + ```bash # Install from npm npm install @jinzcdev/leetcode-mcp-server -g diff --git a/smithery.yaml b/smithery.yaml new file mode 100644 index 0000000..c90eb87 --- /dev/null +++ b/smithery.yaml @@ -0,0 +1,31 @@ +# Smithery configuration file: https://smithery.ai/docs/config#smitheryyaml + +startCommand: + type: stdio + configSchema: + # JSON Schema defining the configuration options for the MCP. + type: object + properties: + site: + type: string + default: global + description: "LeetCode site to target: 'global' for leetcode.com, or 'cn' for leetcode.cn" + session: + type: string + description: Optional session cookie to authenticate with LeetCode API + commandFunction: + # A JS function that produces the CLI command based on the given config to start the MCP on stdio. + |- + (config) => { + const args = ['build/index.js', '--site', config.site]; + if (config.session && config.session.trim() !== '') { + args.push('--session', config.session); + } + return { + command: 'node', + args + }; + } + exampleConfig: + site: global + session: leetcode_session_cookie_value