GXtract is a Model Context Protocol (MCP) server designed to integrate with VS Code and other compatible editors. It provides a suite of tools for interacting with the GroundX platform, enabling you to leverage its powerful document understanding capabilities directly within your development environment. - Architecture - Prerequisites - Installing UV - Quick Start: VS Code Integration - Available
Add this skill
npx mdskills install sascharo/gxtractWell-documented MCP server with useful GroundX integration, clear setup, and caching
1# GXtract MCP Server23<div style="text-align: left;">4 <img src="docs/sphinx/source/_static/images/gxtract-logo.png" alt="GXtract Logo" width="200"/>5</div>67[](https://sascharo.github.io/gxtract/)8[](https://www.python.org/)9[](https://github.com/astral-sh/uv)10[](https://github.com/astral-sh/ruff)11[](https://www.gnu.org/licenses/gpl-3.0)1213GXtract is a Model Context Protocol (MCP) server designed to integrate with VS Code and other compatible editors. It provides a suite of tools for interacting with the GroundX platform, enabling you to leverage its powerful document understanding capabilities directly within your development environment.1415## Table of Contents1617- [Features](#features)18- [Architecture](#architecture)19- [Prerequisites](#prerequisites)20- [Installing UV](#installing-uv)21- [Quick Start: VS Code Integration](#quick-start-vs-code-integration)22- [Available Tools](#available-tools)23- [Configuration](#configuration)24 - [API Key Security](#api-key-security)25- [Development](#development)26- [Documentation](#documentation)27 - [Building Documentation Locally](#building-documentation-locally)28 - [Building Documentation (Sphinx)](#building-documentation-sphinx)29- [Cache Management](#cache-management)30 - [When to Manually Refresh the Cache](#when-to-manually-refresh-the-cache)31 - [How to Refresh the Cache](#how-to-refresh-the-cache)32 - [Troubleshooting Common Cache Issues](#troubleshooting-common-cache-issues)33 - [Checking Cache Status](#checking-cache-status)34- [Dependency Management](#dependency-management)35 - [Working with Dependencies](#working-with-dependencies)36 - [The uv.lock File](#the-uvlock-file)37- [Versioning](#versioning)38- [License](#license)3940## Features4142* **GroundX Integration:** Access GroundX functionalities like document search, querying, and semantic object explanation.43* **MCP Compliant:** Built for use with VS Code's MCP client and other MCP-compatible systems.44* **Efficient and Modern:** Developed with Python 3.12+ and FastMCP v2 for performance.45* **Easy to Configure:** Simple setup for VS Code.46* **Caching:** In-memory cache for GroundX metadata to improve performance and reduce API calls.4748## Architecture4950The high-level system architecture of GXtract illustrates how the components interact:5152```mermaid53graph TB54 subgraph "Client"55 VSC[VS Code / Editor]56 end5758 subgraph "GXtract MCP Server"59 MCP[MCP Interface<br>stdio/http]60 Server[GXtract Server]61 Cache[Metadata Cache]62 Tools[Tool Implementations]63 end6465 subgraph "External Services"66 GXAPI[GroundX API]67 end6869 VSC -->|MCP Protocol| MCP70 MCP --> Server71 Server --> Tools72 Tools -->|Query| GXAPI73 Tools -->|Read/Write| Cache74 Cache -.->|Refresh| GXAPI75```7677This diagram shows:78791. **Client Integration**: VS Code communicates with GXtract using the MCP protocol802. **Transport Layer**: Supports both stdio (for direct VS Code integration) and HTTP transport813. **Core Components**: Server manages tool registration and requests824. **Caching Layer**: Maintains metadata to reduce API calls835. **Tool Implementation**: Provides specialized functions for interacting with GroundX846. **API Communication**: Secure connection to GroundX platform8586For more detailed architecture information, see the [full documentation](https://sascharo.github.io/gxtract/architecture.html).8788## Prerequisites8990* **Python 3.12 or higher.**91* **UV (Python package manager):** Version 0.7.6 or higher. You can install it from [astral.sh/uv](https://astral.sh/uv).92* **GroundX API Key:** You need a valid API key from the [GroundX Dashboard](https://dashboard.groundx.ai/).9394## Installing UV9596Before you can use GXtract, you need to install UV (version 0.7.6 or higher), a modern Python package manager written in Rust that offers significant performance improvements over traditional tools.9798### Quick Installation Methods99100**Windows (PowerShell 7):**101```powershell102powershell -c "irm https://astral.sh/uv/install.ps1 | iex"103```104105**macOS and Linux:**106```bash107curl -LsSf https://astral.sh/uv/install.sh | sh108```109110### Alternative Installation Methods111112**Using pip:**113```bash114pip install --upgrade uv115```116117**Using Homebrew (macOS):**118```bash119brew install uv120```121122**Using pipx (isolated environment):**123```bash124pipx install uv125```126127After installation, verify that UV is working correctly:128```bash129uv --version130```131132This should display version 0.7.6 or higher. For more information about UV, visit the [official documentation](https://docs.astral.sh/uv/).133134## Quick Start: VS Code Integration1351361. **Clone the GXtract Repository:**137 ```bash138 git clone <repository_url> # Replace <repository_url> with the actual URL139 cd gxtract140 ```1411422. **Install Dependencies using UV:**143 Open a terminal in the `gxtract` project directory and run:144 ```powershell145 uv sync146 ```147 This command creates a virtual environment (if one doesn't exist or isn't active) and installs all necessary dependencies specified in `pyproject.toml` and `uv.lock`.1481493. **Set GroundX API Key:**150 The GXtract server requires your GroundX API key. You need to make this key available as an environment variable named `GROUNDX_API_KEY`.151 VS Code will pass this environment variable to the server based on the configuration below. Ensure `GROUNDX_API_KEY` is set in the environment where VS Code is launched, or configure your shell profile (e.g., `.bashrc`, `.zshrc`, PowerShell Profile) to set it.152153 **Option 1: Using Environment Variables (as shown above)**154155 This approach reads the API key from your system environment variables:156157 ```json158 "env": {159 "GROUNDX_API_KEY": "${env:GROUNDX_API_KEY}"160 }161 ```162163 **Option 2: Using VS Code's Secure Inputs**164165 VS Code can prompt for your API key and store it securely. Add this to your `settings.json`:166167 ```json168 "inputs": [169 {170 "type": "promptString",171 "id": "groundx-api-key",172 "description": "GroundX API Key",173 "password": true174 }175 ]176 ```177178 Then reference it in your server configuration:179180 ```json181 "env": {182 "GROUNDX_API_KEY": "${input:groundx-api-key}"183 }184 ```185186 With this approach, VS Code will prompt you for the API key the first time it launches the server, then store it securely in your system's credential manager (Windows Credential Manager, macOS Keychain, or similar).1871884. **Configure VS Code `settings.json`:**189 Open your VS Code `settings.json` file (Ctrl+Shift+P, then search for "Preferences: Open User Settings (JSON)"). Add or update the `mcp.servers` configuration:190 ```jsonc191 "mcp": {192 "servers": {193 "gxtract": { // You can name this server entry as you like, i.e. GXtract194 "command": "uv",195 "type": "stdio", // ๐ก http is also supported but VS Code only supports stdio currently196 "args": [197 // Adjust the path to your gxtract project directory if it's different198 "--directory",199 "DRIVE:\\path\\to\\your\\gxtract", // Example: C:\\Users\\yourname\\projects\\gxtract200 "--project",201 "DRIVE:\\path\\to\\your\\gxtract", // Example: C:\\Users\\yourname\\projects\\gxtract202 "run",203 "gxtract", // This matches the script name in pyproject.toml204 "--transport",205 "stdio" // ๐ก Ensure this matches the "type" above206 ],207 "env": {208 // Option 1: Using environment variables (system-wide)209 "GROUNDX_API_KEY": "${env:GROUNDX_API_KEY}"210211 // Option 2: Using secure VS Code input (uncomment to use)212 // "GROUNDX_API_KEY": "${input:groundx-api-key}"213 }214 }215 }216 }217 ```218 If using Option 2 (secure inputs), add this section (`settings.json`):219 ```jsonc220 // ๐ก Only needed for Option 2 (secure inputs)221 "inputs": [222 {223 "type": "promptString",224 "id": "groundx-api-key",225 "description": "GroundX API Key",226 "password": true227 }228 ]229 ```230 **Important:**231 * Replace `"DRIVE:\\path\\to\\your\\gxtract"` with the **absolute path** to the `gxtract` directory on your system.232 * The `"command": "uv"` assumes `uv` is in your system's PATH. If not, you might need to provide the full path to the `uv` executable.233 * The server name `"GXtract"` in `settings.json` is how it will appear in VS Code's MCP interface.2342355. **Reload VS Code:**236 After saving `settings.json`, you might need to reload VS Code (Ctrl+Shift+P, "Developer: Reload Window") for the changes to take effect.2372386. **Using GXtract Tools:**239 Once configured, you can access GXtract's tools through VS Code's MCP features (e.g., via chat `@` mentions if your VS Code version supports it, or other MCP integrations).240241## Available Tools242243GXtract provides the following tools for interacting with GroundX:244245* `groundx/searchDocuments`: Search for documents within your GroundX projects.246* `groundx/queryDocument`: Ask specific questions about a document in GroundX.247* `groundx/explainSemanticObject`: Get explanations for diagrams, tables, or other semantic objects within documents.248* `cache/refreshMetadataCache`: Manually refresh the GroundX metadata cache.249* `cache/refreshCachedResources`: Manually refresh the GroundX projects and buckets cache.250* `cache/getCacheStatistics`: Get statistics about the cached metadata.251* `cache/listCachedResources`: List all currently cached GroundX resources (projects, buckets).252253## Configuration254255The server can be configured via command-line arguments when run directly. When used via VS Code, these are typically set in the `args` array in `settings.json`.256257* `--transport {stdio|http}`: Communication transport type (default: `http`, but `stdio` is used for VS Code).258* `--host TEXT`: Host address for HTTP transport (default: `127.0.0.1`).259* `--port INTEGER`: Port for HTTP transport (default: `8080`).260* `--log-level {DEBUG|INFO|WARNING|ERROR|CRITICAL}`: Logging level (default: `INFO`).261* `--log-format {text|json}`: Log output format (default: `text`).262* `--disable-cache`: Disable the GroundX metadata cache.263* `--cache-ttl INTEGER`: Cache Time-To-Live in seconds (default: `3600`).264265### API Key Security266267The GroundX API key is sensitive information that should be handled securely. GXtract supports several approaches to provide this key:2682691. **Environment Variables** (recommended for development):270 - Set `GROUNDX_API_KEY` in your system or shell environment271 - VS Code will pass it to the server using `${env:GROUNDX_API_KEY}` in settings.json2722732. **VS Code Secure Storage** (recommended for shared workstations):274 - Configure VS Code to prompt for the key and store it securely275 - Uses your system's credential manager (Windows Credential Manager, macOS Keychain)276 - Setup using the `inputs` section in settings.json as shown in the Quick Start2772783. **Direct Environment Variable in VS Code settings** (not recommended):279 - It's possible to set the key directly in settings.json: `"GROUNDX_API_KEY": "your-api-key-here"`280 - This is not recommended as it stores the key in plaintext in your settings.json file281282Always ensure your API key is not committed to source control or shared with unauthorized users.283284## Development285286To set up for development:2872881. Clone the repository.2892. Navigate to the `gxtract` directory.2903. Create and activate a virtual environment using `uv`:291 ```powershell292 uv venv # Create virtual environment in .venv293 ```294 * Activate with Windows PowerShell:295 ```powershell296 .\.venv\Scripts\Activate.ps1297 ```298 * Activate with Linux/macOS bash/zsh:299 ```bash300 source .venv/bin/activate301 ```3024. Install main project dependencies into the virtual environment:303 ```powershell304 uv sync # Install main dependencies from pyproject.toml305 ```306 Development tools (like Ruff, Pytest, Sphinx, etc.) are managed by Hatch and will be installed automatically307 into a separate environment when you run Hatch scripts (see below).308 Alternatively, to explicitly create or ensure the Hatch 'default' development environment is set up:309 ```powershell310 hatch env create default # Ensure your main .venv is active first311 ```312 If you need to force a complete refresh of this environment, you can remove it first313 with 'hatch env remove default' before running 'hatch env create default'.314315Run linters/formatters (this will also install them via Hatch if not already present):316```powershell317uv run lint318uv run format319```320321## Documentation322323The full documentation for GXtract is available at [https://sascharo.github.io/gxtract/](https://sascharo.github.io/gxtract/).324325### Building Documentation Locally326327If you want to build and view the documentation locally:3283291. Ensure you have installed all development dependencies:330 ```bash331 uv sync332 ```3333342. Build the documentation:335 ```bash336 uv run hatch -e default run docs-build337 ```3383393. Serve the documentation locally:340 ```bash341 uv run hatch -e default run docs-serve342 ```3433444. Open your browser and navigate to [http://127.0.0.1:8000](http://127.0.0.1:8000)345346### Building Documentation (Sphinx)347348The project documentation is built using [Sphinx](https://www.sphinx-doc.org/). The following Hatch scripts are available to manage the documentation:349350* **Build Documentation:**351 ```bash352 uv run docs-build353 ```354 This command generates the HTML documentation in the `docs/sphinx/build/html` directory.355356* **Serve Documentation Locally:**357 ```bash358 uv run docs-serve359 ```360 This starts a local HTTP server (usually at `http://127.0.0.1:8000`) to preview the documentation. You can specify a different port if needed, e.g., `uv run docs-serve 8081`.361362* **Clean Documentation Build:**363 ```bash364 uv run docs-clean365 ```366 This command removes the `docs/sphinx/build` directory, cleaning out old build artifacts.367368Ensure your virtual environment is active before running these commands.369370## Cache Management371372GXtract maintains an in-memory cache of GroundX metadata (projects and buckets) to improve performance and reduce API calls. While this cache is automatically populated during server startup and periodically refreshed, there are situations when you may need to manually refresh the cache.373374### When to Manually Refresh the Cache375376You should manually refresh the cache when:3773781. You've recently created new projects or buckets in your GroundX account and want them to be immediately available in GXtract.3792. You see warnings in the server logs about cache population failures.3803. You're experiencing issues with project or bucket lookup when using GXtract tools.381382### How to Refresh the Cache383384#### Using VS Code's MCP Interface385386If your VS Code version supports MCP chat interfaces:3873881. Open VS Code's chat interface.3892. Use the `@GXtract` mention (or whatever name you assigned to the server in your settings).3903. Type a command to refresh the cache:391 ```392 @GXtract Please refresh the GroundX metadata cache393 ```3944. The VS Code interface will use the appropriate cache refresh tool.395396#### Using Direct JSON-RPC Requests397398If you have access to the server through HTTP (when not using stdio transport), you can make direct requests:399400```bash401curl -X POST http://127.0.0.1:8080/jsonrpc -H "Content-Type: application/json" -d '{402 "jsonrpc": "2.0",403 "method": "cache/refreshMetadataCache",404 "params": {},405 "id": "refresh-req-001"406}'407```408409### Troubleshooting Common Cache Issues410411#### Warning: "No projects (groups) found or 'groups' attribute missing in API response"412413This warning indicates that:414- Your API key might not have access to any projects, or415- No projects have been created in your GroundX account yet, or416- There might be an issue with the GroundX API or connectivity.417418**Solution**:4191. Verify you have correctly set up your GroundX account with at least one project.4202. Check that your API key has proper permissions.4213. Try refreshing the cache manually after confirming your account setup.422423#### Warning: "GroundX metadata cache population failed. Check logs for details"424425This warning appears during server startup if the initial cache population failed.426427**Solution**:4281. Check the full server logs for more details about the error.4292. Verify your API key is correctly set in the environment.4303. Check your internet connection and GroundX API availability.4314. Try using the `cache/refreshMetadataCache` tool to manually populate the cache.432433### Checking Cache Status434435You can check the current status of the cache with:436437```json438{439 "jsonrpc": "2.0",440 "method": "cache/getCacheStatistics",441 "params": {},442 "id": "stats-req-001"443}444```445446Or list the currently cached resources:447448```json449{450 "jsonrpc": "2.0",451 "method": "cache/listCachedResources",452 "params": {},453 "id": "list-req-001"454}455```456457## Dependency Management458459GXtract uses [uv](https://github.com/astral-sh/uv) for dependency management. Dependencies are specified in `pyproject.toml` and locked in `uv.lock` to ensure reproducible installations.460461### Working with Dependencies462463- **Installing dependencies**: Run `uv sync` to install all dependencies according to the lockfile.464- **Adding a new dependency**: Add the dependency to `pyproject.toml` and run `uv pip compile pyproject.toml -o uv.lock` to update the lockfile.465- **Updating dependencies**: After manually changing versions in `pyproject.toml`, run `uv pip compile pyproject.toml -o uv.lock --upgrade` to update the lockfile with newest compatible versions.466467### The uv.lock File468469The `uv.lock` file is committed to the repository to ensure that everyone working on the project uses exactly the same dependency versions. This prevents "works on my machine" problems and ensures consistent behavior across development environments and CI/CD pipelines.470471When making changes to dependencies, always commit both the updated `pyproject.toml` and the `uv.lock` file.472473## Versioning474475This project adheres to [Semantic Versioning (SemVer 2.0.0)](https://semver.org/spec/v2.0.0.html).476477## License478479This project is licensed under the GNU General Public License v3.0 - see the [LICENSE.md](LICENSE.md) file for details.480
Full transparency โ inspect the skill content before installing.