TwinCAT Knowledge MCP Server

TwinCAT Knowledge MCP Server

Enables semantic search over TwinCAT 3 documentation using natural language queries, with intelligent caching for fast results.

Category
Visit Server

README

TwinCAT Knowledge MCP Server

A Model Context Protocol (MCP) server providing semantic search access to TwinCAT 3 documentation. This project includes tools for converting PDFs to Markdown, generating embeddings, and hosting a searchable API on GitHub Pages.

Overview

This project provides a complete semantic search solution for TwinCAT 3 documentation:

  1. PDF Conversion: Converts 290 TwinCAT 3 documentation PDFs from Beckhoff to Markdown format
  2. Embedding Generation: Generates semantic embeddings using transformer models
  3. Search API: Hosts a search API on GitHub Pages using Transformers.js
  4. MCP Server: Provides an MCP-compatible interface for Cursor and LM Studio

Architecture

[Generate Embeddings] → Push to GitHub
            ↓
[GitHub Pages] → Transformers.js API
            ↓
[Local MCP Server] → Returns to Cursor/LM Studio

Features

  • Semantic Search: Natural language search using transformer-based embeddings
  • Persistent Cache: Intelligent caching system for 90% faster subsequent searches
  • GitHub Pages API: Free, unlimited hosting with Transformers.js
  • Rich Metadata: Structured YAML frontmatter for advanced filtering
  • Category Support: Search by product, category, version, and more
  • No GPU Required: The MCP server runs on CPU, works on any machine

Quick Start

Local Installation

  1. Clone the repository:
git clone https://github.com/njfsmallet-eng/twincat-knowledge-mcp-server.git
cd twincat-knowledge-mcp-server
  1. Install dependencies:
npm install
  1. Build the project:
npm run build

This compiles TypeScript to JavaScript in the dist/ directory. The dist/ folder is not tracked in git, so you need to build after cloning.

Note: You only need to rebuild if you modify the source code. The compiled dist/ files are not committed to git.

  1. Add to your Cursor/LM Studio mcp.json:

Option A: Using compiled CommonJS (Recommended)

{
  "mcpServers": {
    "twincat-knowledge": {
      "command": "node",
      "args": ["C:\\Users\\YourUsername\\path\\to\\twincat-knowledge-mcp-server\\dist\\index.js"],
      "env": {}
    }
  }
}

Option B: Using TypeScript directly

{
  "mcpServers": {
    "twincat-knowledge": {
      "command": "npx",
      "args": ["-y", "tsx", "C:\\Users\\YourUsername\\path\\to\\twincat-knowledge-mcp-server\\src\\index.ts"],
      "env": {}
    }
  }
}

Note: Replace the path with your actual repository location. Use double backslashes (\\) for Windows paths.

Configuration for Different Platforms

The configuration works identically across all compatible platforms:

  • Cursor: Uses the mcp.json file in your user directory (typically C:\Users\YourUsername\.cursor\mcp.json on Windows)
  • LM Studio: Uses the same MCP server configuration format

Both platforms support the standard MCP stdio protocol used by this server.

Usage

Using the MCP Server

Once configured in Cursor or LM Studio, use the search_knowledge tool:

"Describe what TwinCAT Scope is and its main features."

Available filters:

  • category: Communication, PLC, Motion_Control, etc.
  • product: TF6100, TC3, TE1000, etc.
  • top_k: Number of results (default: 5)

Cache System

The MCP server includes an intelligent caching system that dramatically improves performance:

  • First call: Downloads and caches all data (~16 seconds)
  • Subsequent calls: Loads from cache (~1.6 seconds)
  • Performance improvement: 90% faster after initial cache population
  • Cache location: .cache/ directory in project root
  • Persistent: Cache survives between MCP server sessions
  • Automatic: No manual configuration required

Cache contents:

  • Xenova embedding model (~50 MB)
  • Documentation chunks (42,314 chunks)
  • Pre-computed embeddings (~57 MB compressed)

Testing the Search API

You can test the search functionality directly in your browser at: https://njfsmallet-eng.github.io/twincat-knowledge-mcp-server/

This web interface allows you to:

  • Test semantic search queries
  • See real-time results from the TwinCAT documentation
  • Verify that the API is working correctly before configuring Cursor or LM Studio

File Structure

twincat-knowledge-mcp-server/
├── src/                         # TypeScript source
│   ├── index.ts                # MCP server
│   ├── types.ts                # Type definitions
│   ├── github-pages-client.ts  # API client
│   └── cache-manager.ts        # Cache management
├── dist/                        # Compiled JavaScript (CommonJS)
│   ├── index.js                # Compiled MCP server
│   └── *.js                     # Other compiled files
├── scripts/                     # Python scripts
│   ├── chunking.py             # Text chunking
│   ├── generate_embeddings.py  # Embedding generation
│   └── README.md               # Scripts documentation
├── gh-pages/                    # GitHub Pages files
│   ├── index.html              # API interface
│   └── search.js               # Transformers.js search
├── embeddings/                  # Generated embeddings
│   ├── chunks.json             # Chunks with metadata
│   ├── embeddings.npy.gz       # Compressed vectors
│   └── metadata.json           # Generation stats
├── docs/                        # Converted markdown docs
├── .cache/                      # Persistent cache (auto-created)
│   ├── chunks.json             # Cached documentation chunks
│   ├── embeddings.npy.gz       # Cached embeddings
│   └── model/                  # Xenova model cache
│       └── Xenova/
│           └── all-MiniLM-L6-v2/
├── .github/workflows/           # CI/CD
│   └── deploy-pages.yml        # GitHub Pages deployment
├── package.json                 # Node.js config
├── tsconfig.json               # TypeScript config
└── requirements.txt            # Python dependencies

Dependencies

Python (for embedding generation only):

  • sentence-transformers - Transformer models for embeddings
  • torch - PyTorch
  • numpy - Numerical operations
  • pyyaml - YAML parsing
  • tqdm - Progress bars

Note: Python dependencies are only needed to generate embeddings. The MCP server itself requires only Node.js.

Node.js:

  • @modelcontextprotocol/sdk - MCP protocol
  • @xenova/transformers - Transformers.js for embeddings
  • typescript - TypeScript compiler (for building)

The project compiles TypeScript to CommonJS for optimal Node.js compatibility.

Architecture Details

Embedding Generation

  • Model: sentence-transformers/all-MiniLM-L6-v2 (384 dimensions)
  • Format: Float32 NumPy arrays compressed with gzip
  • Size: ~57 MB compressed for all documents
  • Note: Embeddings are pre-generated and hosted on GitHub Pages. The MCP server does not require any GPU or Python dependencies to run.

Search API

  • Frontend: Transformers.js in browser
  • Model: Xenova/all-MiniLM-L6-v2 ONNX (quantized)
  • Latency: ~500ms-1s per query
  • Cache: IndexedDB for model caching

MCP Server

  • Transport: stdio
  • Compatibility: Cursor, LM Studio (tested)
  • Module System: CommonJS (compiled from TypeScript)
  • Language: TypeScript source, compiled to JavaScript
  • Local Installation: Clone and configure directly
  • Cache System: Persistent disk-based caching for optimal performance
  • Performance: 90% faster after initial cache population

Local Usage

Requirements

  • Node.js: >=18.0.0
  • TypeScript: >=5.9.0 (for building)
  • Dependencies: Only MCP SDK and Transformers.js required
  • Size: ~160 MB (includes embeddings and documentation)
  • Cache: Additional ~110 MB for persistent cache (auto-created)
  • Build: Run npx tsc to compile TypeScript to CommonJS in dist/ directory
  • Files: 338 files total

License

MIT License

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured