A cross-platform command-line learning app that integrates with Microsoft Learn documentation via MCP (Model Context Protocol).
- Node.js 18 or higher
- npm (comes with Node.js)
- Clone the repository:
git clone https://github.com/pdebruin/learncli.git
cd learncli- Install dependencies:
npm install- Build the project:
npm run buildThis will compile the TypeScript source code from the src/ directory to JavaScript in the dist/ directory.
After building, you can run the CLI in several ways:
# Show help
node dist/index.js
# Search Microsoft Learn documentation
node dist/index.js docs -q "your search query"
# Example search
node dist/index.js docs -q "azure functions"
# Code command (placeholder)
node dist/index.js code# Show help
npm start
# Search with a query (note the -- before arguments)
npm start -- docs -q "your search query"
# Example
npm start -- docs -q "azure functions"Note: When using npm start, you must include -- before the arguments to pass them correctly to the script.
The CLI provides execution progress logs when searching documentation:
[INFO]logs show the execution flow (endpoint validation, MCP connection, tool calling, etc.)[ERROR]logs show any errors encountered[RESULTS]logs show the search results[RESPONSE]logs show the raw response from the MCP server
To enable detailed debug logging, set the DEBUG environment variable:
# On Linux/macOS
DEBUG=true node dist/index.js docs -q "your search query"
# On Windows (PowerShell)
$env:DEBUG="true"; node dist/index.js docs -q "your search query"
# On Windows (CMD)
set DEBUG=true && node dist/index.js docs -q "your search query"For active development, you can use the watch mode to automatically recompile TypeScript files when they change:
# Start TypeScript compiler in watch mode
npm run devThis will keep running and recompile your code whenever you save changes to .ts files. In a separate terminal, you can then run the compiled code:
# In another terminal
node dist/index.js docs -q "test query"npm run build- Compiles TypeScript to JavaScript (one-time build)npm run dev- Compiles TypeScript in watch mode (auto-recompile on changes)npm start- Builds and runs the CLInpm test- Builds and runs tests (if available)
-
Make sure you have the correct Node.js version:
node --version # Should be 18.x or higher -
Clear node_modules and dist directories, then reinstall:
# On Linux/macOS rm -rf node_modules dist # On Windows (PowerShell) Remove-Item -Recurse -Force node_modules, dist # On Windows (CMD) rmdir /s /q node_modules dist # Then reinstall npm install npm run build
-
Verify TypeScript is installed:
npx tsc --version # Should be 5.x or higher
If you see errors like Cannot find module '@modelcontextprotocol/sdk/...':
-
Ensure all dependencies are installed:
npm install
-
Check that the
node_modulesdirectory exists and contains the required packages:ls node_modules/@modelcontextprotocol/sdk
If the built application fails to run:
-
Make sure you've built the project first:
npm run build
-
Verify the
dist/directory exists and containsindex.js:ls dist/
-
Try running with more verbose output:
DEBUG=true node dist/index.js docs -q "test"