### GitHub Actions Workflow for Publishing Source: https://github.com/upstash/context7-vscode-extension/blob/master/DEPLOYMENT.md A GitHub Actions workflow that automates the publishing process. It checks out the code, sets up Node.js, installs dependencies, compiles the extension, and uses `vsce publish` to deploy it to the marketplace when a new tag starting with 'v' is pushed. It requires a `VSCE_PAT` secret for authentication. ```yaml name: Publish Extension on: push: tags: - 'v*' jobs: publish: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: '18' - run: npm install - run: npm run compile - run: npm install -g @vscode/vsce - run: vsce publish env: VSCE_PAT: ${{ secrets.VSCE_PAT }} ``` -------------------------------- ### Install and Build VS Code Extension Source: https://context7.com/upstash/context7-vscode-extension/llms.txt This bash script outlines the steps for setting up the Context7 VS Code extension. It includes cloning the repository, installing dependencies using npm, compiling the TypeScript code, and enabling watch mode for development. ```bash # Clone the repository git clone https://github.com/upstash/context7-vscode-extension.git cd context7-vscode-extension # Install dependencies (automatically downloads VS Code API definitions) npm install # Build the extension npm run compile # Watch mode for development npm run watch # Launch in VS Code Extension Development Host # Press F5 in VS Code to start debugging ``` -------------------------------- ### Example Prompt with Direct Library Access (Plain Text) Source: https://github.com/upstash/context7-vscode-extension/blob/master/README.md An example of how to directly specify a library ID in a prompt for the AI assistant. ```plaintext "Implement basic authentication with Supabase. Use the API and documentation from the /supabase/supabase library." ``` -------------------------------- ### Install vsce Tool Source: https://github.com/upstash/context7-vscode-extension/blob/master/DEPLOYMENT.md Installs the Visual Studio Code Extension Manager (`vsce`) globally using npm. This tool is essential for packaging and publishing VS Code extensions. ```bash npm install -g @vscode/vsce ``` -------------------------------- ### Install Dependencies and Build Extension (Bash) Source: https://github.com/upstash/context7-vscode-extension/blob/master/README.md Commands to install project dependencies and compile the TypeScript code for the VS Code extension. ```bash npm install npm run compile ``` -------------------------------- ### MCP Function: get-library-docs Source: https://context7.com/upstash/context7-vscode-extension/llms.txt This comment block describes the `get-library-docs` MCP function, responsible for fetching up-to-date documentation using a Context7 library ID. It outlines example prompts that trigger documentation fetching and details the automatic process of library resolution, documentation retrieval, and example provision by the MCP server. ```comment // MCP function: mcp_context7-new_get-library-docs // Fetches latest documentation after library ID resolution // Example prompts that utilize documentation fetching: // "What are the best practices for Next.js routing? use context7" // "How do I implement authentication with Supabase? use context7" // "Give me examples of using TypeScript decorators use context7" // "How do I set up a GraphQL server with Apollo? use context7" // "What are the latest features in Node.js 20? use context7" // The MCP server automatically: // 1. Resolves the library name to the appropriate Context7 library ID // 2. Fetches the latest documentation // 3. Provides relevant code examples and documentation ``` -------------------------------- ### Changelog Format Source: https://github.com/upstash/context7-vscode-extension/blob/master/DEPLOYMENT.md An example of a `CHANGELOG.md` file following a structured format for documenting changes across different versions of the extension. It includes version numbers, dates, and categorized changes (Added, Fixed, Changed, etc.). ```markdown # Changelog ## [1.0.0] - 2024-01-01 ### Added - Initial release - Context7 MCP server integration - Real-time documentation access for AI assistants ## [1.0.1] - 2024-01-15 ### Fixed - Fixed TypeScript compilation issues ``` -------------------------------- ### Build and Package Extension Source: https://github.com/upstash/context7-vscode-extension/blob/master/DEPLOYMENT.md Commands to install project dependencies, compile the TypeScript code, and package the VS Code extension into a `.vsix` file. The `.vsix` file can be used for local testing or publishing. ```bash npm install npm run compile vsce package ``` -------------------------------- ### Publish Extension to Marketplace Source: https://github.com/upstash/context7-vscode-extension/blob/master/DEPLOYMENT.md Publishes the VS Code extension to the Visual Studio Code Marketplace. This command can be used for initial publishing (`--new`) or updating existing versions using semantic versioning increments (patch, minor, major). ```bash vsce publish --new vsce publish patch vsce publish minor vsce publish major ``` -------------------------------- ### Update Extension Metadata in package.json Source: https://github.com/upstash/context7-vscode-extension/blob/master/DEPLOYMENT.md Defines the metadata for the VS Code extension, including its name, display name, description, version, publisher, repository, keywords, and categories. This JSON file is crucial for the extension's identity and discoverability on the marketplace. ```json { "name": "context7-mcp", "displayName": "Context7 MCP Server", "description": "Real-time documentation access for AI assistants via Context7 MCP server", "version": "1.0.0", "publisher": "your-publisher-name", "private": false, "repository": { "type": "git", "url": "https://github.com/your-username/context7-vscode-extension.git" }, "keywords": [ "mcp", "context7", "documentation", "ai", "assistant" ], "categories": [ "Other" ] } ``` -------------------------------- ### Launch Extension in VS Code (Bash) Source: https://github.com/upstash/context7-vscode-extension/blob/master/README.md Command to launch the VS Code extension in a new Extension Development Host window for testing. ```bash npm run compile Press F5 in VS Code ``` -------------------------------- ### Main Extension Code (TypeScript) Source: https://github.com/upstash/context7-vscode-extension/blob/master/README.md The main entry point for the VS Code extension, responsible for registering the Context7 MCP server. ```typescript import * as vscode from "vscode"; import { Context7MCP } from "@upstash/context7-mcp"; export function activate(context: vscode.ExtensionContext) { console.log('Congratulations, your extension "context7-vscode-extension" is now active!'); const mcp = new Context7MCP(); context.subscriptions.push(mcp); // Register MCP server definition provider vscode.languages.registerInlineCompletionItemProvider( { scheme: "file", language: "typescript" }, // Example language, adjust as needed mcp.getProvider() ); console.log('Context7 MCP Server registered.'); } export function deactivate() {} ``` -------------------------------- ### VS Code Extension Manifest (package.json) Source: https://context7.com/upstash/context7-vscode-extension/llms.txt This JSON configuration file defines the Context7 MCP Server extension's manifest. It specifies the extension's name, version, publisher, VS Code engine compatibility, categories, main entry point, MCP server definition provider, and dependencies, including the `@upstash/context7-mcp` package. ```json { "name": "context7-mcp", "displayName": "Context7 MCP Server", "description": "Real-time code and documentation access for AI assistants via Context7 MCP server", "version": "1.0.1", "publisher": "Upstash", "engines": { "vscode": "^1.101.0" }, "categories": ["AI", "Chat"], "main": "./out/extension.js", "contributes": { "mcpServerDefinitionProviders": [ { "id": "context7", "label": "Context7" } ] }, "dependencies": { "@upstash\/context7-mcp": "1.0.14" }, "scripts": { "compile": "tsc -p ./", "watch": "tsc -watch -p ./" } } ``` -------------------------------- ### Activate VS Code Extension and Register MCP Server Source: https://context7.com/upstash/context7-vscode-extension/llms.txt This TypeScript code activates the VS Code extension and registers the Context7 MCP server definition provider. It allows AI assistants to access documentation for various frameworks by providing a path to the MCP server implementation. ```typescript import * as vscode from 'vscode'; import * as path from 'path'; export function activate(context: vscode.ExtensionContext) { // Register Context7 MCP Server definition provider context.subscriptions.push(vscode.lm.registerMcpServerDefinitionProvider('context7', { provideMcpServerDefinitions(): vscode.McpServerDefinition[] { return [ new vscode.McpStdioServerDefinition( 'context7', 'node', [ path.join(__dirname, '..', 'node_modules', '@upstash', 'context7-mcp', 'dist', 'index.js'), ] ) ]; } })); } export function deactivate() { } ``` -------------------------------- ### MCP Function: resolve-library-id Source: https://context7.com/upstash/context7-vscode-extension/llms.txt This comment block describes the `resolve-library-id` MCP function, which resolves package or product names to a Context7-compatible library ID. It's automatically invoked by the MCP server during query processing and demonstrates usage with natural language prompts and direct library access syntax. ```comment // MCP function: mcp_context7-new_resolve-library-id // Automatically resolves library names from natural language queries // Example AI prompt that triggers library resolution: // "Show me how to use React hooks use context7" // The MCP server will resolve "React" to its Context7 library ID // Direct library access using slash syntax: // "Implement basic authentication with Supabase. Use the API and documentation from the /supabase/supabase library." ``` -------------------------------- ### TypeScript Build Configuration (tsconfig.json) Source: https://context7.com/upstash/context7-vscode-extension/llms.txt This JSON file configures the TypeScript compiler for the VS Code extension. It specifies compiler options such as module system, target ECMAScript version, included libraries, output directory, source map generation, strict type checking, and the root directory for source files. ```json { "compilerOptions": { "module": "commonjs", "target": "es2022", "lib": ["es2022", "dom"], "outDir": "out", "sourceMap": true, "strict": true, "rootDir": "src" }, "exclude": ["node_modules", ".vscode-test"] } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.