# Directory Structure ``` ├── .gitattributes ├── .gitignore ├── .vscode │ ├── launch.json │ ├── mcp.json │ └── tasks.json ├── package-lock.json ├── package.json ├── README.md ├── src │ ├── index.ts │ └── server.ts └── tsconfig.json ``` # Files -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- ``` 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | ``` -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- ``` 1 | .DS_Store 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-debug.log* 9 | 10 | # Diagnostic reports (https://nodejs.org/api/report.html) 11 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 12 | 13 | # Runtime data 14 | pids 15 | *.pid 16 | *.seed 17 | *.pid.lock 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | *.lcov 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 30 | .grunt 31 | 32 | # Bower dependency directory (https://bower.io/) 33 | bower_components 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (https://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules/ 43 | jspm_packages/ 44 | 45 | # Snowpack dependency directory (https://snowpack.dev/) 46 | web_modules/ 47 | 48 | # TypeScript cache 49 | *.tsbuildinfo 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Optional stylelint cache 58 | .stylelintcache 59 | 60 | # Microbundle cache 61 | .rpt2_cache/ 62 | .rts2_cache_cjs/ 63 | .rts2_cache_es/ 64 | .rts2_cache_umd/ 65 | 66 | # Optional REPL history 67 | .node_repl_history 68 | 69 | # Output of 'npm pack' 70 | *.tgz 71 | 72 | # Yarn Integrity file 73 | .yarn-integrity 74 | 75 | # dotenv environment variable files 76 | .env 77 | .env.development.local 78 | .env.test.local 79 | .env.production.local 80 | .env.local 81 | 82 | # parcel-bundler cache (https://parceljs.org/) 83 | .cache 84 | .parcel-cache 85 | 86 | # Next.js build output 87 | .next 88 | out 89 | 90 | # Nuxt.js build / generate output 91 | .nuxt 92 | dist 93 | 94 | # Gatsby files 95 | .cache/ 96 | # Comment in the public line in if your project uses Gatsby and not Next.js 97 | # https://nextjs.org/blog/next-9-1#public-directory-support 98 | # public 99 | 100 | # vuepress build output 101 | .vuepress/dist 102 | 103 | # vuepress v2.x temp and cache directory 104 | .temp 105 | .cache 106 | 107 | # vitepress build output 108 | **/.vitepress/dist 109 | 110 | # vitepress cache directory 111 | **/.vitepress/cache 112 | 113 | # Docusaurus cache and generated files 114 | .docusaurus 115 | 116 | # Serverless directories 117 | .serverless/ 118 | 119 | # FuseBox cache 120 | .fusebox/ 121 | 122 | # DynamoDB Local files 123 | .dynamodb/ 124 | 125 | # TernJS port file 126 | .tern-port 127 | 128 | # Stores VSCode versions used for testing VSCode extensions 129 | .vscode-test 130 | 131 | # yarn v2 132 | .yarn/cache 133 | .yarn/unplugged 134 | .yarn/build-state.yml 135 | .yarn/install-state.gz 136 | .pnp.* ``` -------------------------------------------------------------------------------- /.vscode/mcp.json: -------------------------------------------------------------------------------- ```json 1 | { 2 | "servers": { 3 | "grok2-image-mcp-server": { 4 | "type": "stdio", 5 | "command": "node", 6 | "args": ["${workspaceFolder}/dist/index.js"] 7 | } 8 | } 9 | } 10 | ``` -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- ```json 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "type": "npm", 6 | "script": "watch", 7 | "problemMatcher": ["$tsc-watch"], 8 | "isBackground": true, 9 | "label": "npm: watch", 10 | "group": { 11 | "kind": "build", 12 | "isDefault": true 13 | } 14 | } 15 | ] 16 | } 17 | ``` -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- ```json 1 | { 2 | "compilerOptions": { 3 | "target": "ES2022", 4 | "module": "Node16", 5 | "moduleResolution": "Node16", 6 | "outDir": "./dist", 7 | "rootDir": "./src", 8 | "strict": true, 9 | "esModuleInterop": true, 10 | "skipLibCheck": true, 11 | "forceConsistentCasingInFileNames": true, 12 | "sourceMap": true 13 | }, 14 | "include": ["src/**/*"], 15 | "exclude": ["node_modules"] 16 | } 17 | ``` -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- ```typescript 1 | #!/usr/bin/env node 2 | import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; 3 | import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; 4 | 5 | import { createServer } from "./server.js"; 6 | 7 | async function main() { 8 | const server: McpServer = createServer(); 9 | const transport = new StdioServerTransport(); 10 | await server.connect(transport); 11 | console.debug("Grok2 Image MCP Server running on stdio"); 12 | } 13 | 14 | main().catch((error) => { 15 | console.error("Fatal error in main():", error); 16 | process.exit(1); 17 | }); 18 | ``` -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- ```json 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "type": "node", 6 | "request": "launch", 7 | "name": "Debug MCP Server", 8 | "skipFiles": ["<node_internals>/**"], 9 | "outFiles": ["${workspaceFolder}/dist/**/*.js"], 10 | "runtimeExecutable": "npx", 11 | "runtimeArgs": [ 12 | "-y", 13 | "@modelcontextprotocol/inspector", 14 | "node", 15 | "dist/index.js" 16 | ], 17 | "console": "integratedTerminal", 18 | "preLaunchTask": "npm: watch", 19 | "serverReadyAction": { 20 | "action": "openExternally", 21 | "pattern": "running at (https?://\\S+)", 22 | "uriFormat": "%s?timeout=60000" 23 | } 24 | } 25 | ] 26 | } 27 | ``` -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- ```json 1 | { 2 | "name": "grok2-image-mcp-server", 3 | "version": "0.1.5", 4 | "type": "module", 5 | "bin": { 6 | "grok2-image-mcp-server": "dist/index.js" 7 | }, 8 | "scripts": { 9 | "build": "tsc && shx chmod +x dist/index.js", 10 | "watch": "tsc --watch", 11 | "start": "node ./dist/index.js", 12 | "prepublishOnly": "npm run build" 13 | }, 14 | "files": [ 15 | "dist" 16 | ], 17 | "keywords": [ 18 | "mcp", 19 | "grok2", 20 | "image-generation", 21 | "model-context-protocol" 22 | ], 23 | "repository": { 24 | "type": "git", 25 | "url": "https://github.com/fl0w1nd/grok2-image-mcp-server" 26 | }, 27 | "author": "fl0w1nd", 28 | "license": "MIT", 29 | "description": "Grok2 Image MCP Server", 30 | "dependencies": { 31 | "@modelcontextprotocol/sdk": "^1.7.0", 32 | "undici": "^5.29.0", 33 | "zod": "^3.24.2" 34 | }, 35 | "devDependencies": { 36 | "@types/node": "^22.13.10", 37 | "shx": "^0.3.4", 38 | "typescript": "^5.8.2" 39 | }, 40 | "engines": { 41 | "node": ">=18.0.0" 42 | } 43 | } 44 | ```