TDS MCP Server
# TDS MCP Server
A Model Context Protocol (MCP) server for the Temporal Documentation System (TDS). This server enables AI assistants to interact with TDS projects, providing access to guides, anchors, and patterns.
## Features
- **TDS Resource Access**: Browse and read TDS guides, anchors, and patterns
- **Advanced Multi-layer Search**: Search across all TDS layers with filtering, relevance scoring, and multiple sort options
- **Smart Context Awareness**: Get relevant TDS knowledge for current work context
- **Enhanced Comment Promotion**: Promote LEARNING comments to anchors with automatic cleanup
- **Intelligent Health Reports**: Generate actionable reports with high-value learning detection and pattern candidates
- **Multi-line Comment Support**: Extract full context from multi-line TDS comments
- **Configurable Setup**: Customize behavior with `.tdsrc.json` configuration file
- **Multi-language Support**: Works with JavaScript, TypeScript, Python, Go, Java, C++, C, Rust, Ruby, and PHP
## Installation
1. Navigate to the TDS MCP server directory:
```bash
cd tds-mcp
```
2. Install dependencies:
```bash
npm install
```
3. Build the server:
```bash
npm run build
```
## Usage
### Development Mode
Run the server in development mode with hot reloading:
```bash
npm run dev
```
### Production Mode
Build and run the server:
```bash
npm run build
npm start
```
### MCP Client Configuration
To use this server with an MCP client (like Claude Desktop), add the following configuration:
#### Claude Desktop Configuration
Add to your Claude Desktop configuration file:
```json
{
"mcpServers": {
"tds": {
"command": "node",
"args": ["/path/to/tds-mcp/build/index.js"],
"env": {}
}
}
}
```
## TDS Project Structure
The server expects the following TDS project structure:
```
your-project/
├── anchors/
│ ├── domain/
│ ├── integrations/
│ └── lessons-learned/
├── patterns/
│ ├── error-handling/
│ ├── integrations/
│ └── testing/
└── src/
└── [your code files with TDS comments]
```
## TDS Comment Format
The server recognizes these TDS comment types:
### JavaScript/TypeScript
```javascript
// TODO: Known issues needing attention
// HACK: Temporary workarounds with context
// NOTE: Important context for future changes
// LEARNING: Fresh discoveries and insights
// FIXME: Bugs requiring immediate attention
```
### Python
```python
# TODO: Known issues needing attention
# HACK: Temporary workarounds with context
# NOTE: Important context for future changes
# LEARNING: Fresh discoveries and insights
# FIXME: Bugs requiring immediate attention
```
### Go
```go
// TODO: Known issues needing attention
// HACK: Temporary workarounds with context
// NOTE: Important context for future changes
// LEARNING: Fresh discoveries and insights
// FIXME: Bugs requiring immediate attention
```
## Available Tools
### tds_search
Search across all TDS layers with advanced filtering and relevance scoring.
**Parameters:**
- `query` (required): Search query string
- `layer` (optional): Layer to search in (`guides`, `anchors`, `patterns`, or `all`)
- `comment_type` (optional): Filter by comment type (`TODO`, `HACK`, `NOTE`, `LEARNING`, `FIXME`, or `all`)
- `priority` (optional): Filter by priority level (`high`, `normal`, or `all`)
- `sort_by` (optional): Sort results by (`relevance`, `date`, or `priority`)
**Example:**
```json
{
"tool": "tds_search",
"arguments": {
"query": "payment API",
"layer": "all",
"comment_type": "LEARNING",
"priority": "high",
"sort_by": "relevance"
}
}
```
### tds_report
Generate a TDS health report showing usage statistics.
**Parameters:**
- `detailed` (optional): Include detailed analysis (default: false)
**Example:**
```json
{
"tool": "tds_report",
"arguments": {
"detailed": true
}
}
```
### tds_promote
Promote a LEARNING comment to an anchor document with automatic cleanup.
**Parameters:**
- `file` (required): Source file path
- `line` (required): Line number of the LEARNING comment
- `title` (required): Title for the new anchor
- `category` (optional): Anchor category (`domain`, `integrations`, `lessons-learned`)
**Example:**
```json
{
"tool": "tds_promote",
"arguments": {
"file": "src/payment.js",
"line": 45,
"title": "Payment API Timezone Requirements",
"category": "integrations"
}
}
```
### tds_get_context
Get relevant TDS knowledge for current work context.
**Parameters:**
- `file_path` (optional): Current file path for context
- `topic` (optional): Topic or keyword to find relevant knowledge about
- `type` (optional): Type of context to retrieve (`all`, `anchors`, `patterns`, `learnings`)
**Example:**
```json
{
"tool": "tds_get_context",
"arguments": {
"file_path": "src/payment.js",
"topic": "API authentication",
"type": "all"
}
}
```
## Configuration
The server can be customized using a `.tdsrc.json` configuration file in your project root:
```json
{
"anchorCategories": [
"domain",
"integrations",
"lessons-learned",
"security",
"performance"
],
"patternCategories": [
"error-handling",
"integrations",
"testing",
"security"
],
"includePatterns": {
"guides": [
"**/*.{js,ts,py,go,java,cpp,c,rs,rb,php}",
"**/*.{jsx,tsx,vue,svelte}"
],
"anchors": [
"anchors/**/*.md",
"docs/anchors/**/*.md"
],
"patterns": [
"patterns/**/*.md",
"docs/patterns/**/*.md"
]
},
"excludePatterns": [
"node_modules/**",
"build/**",
"dist/**",
".git/**"
],
"commentTypes": [
"TODO",
"HACK",
"NOTE",
"LEARNING",
"FIXME",
"WARNING"
],
"highPriorityKeywords": [
"critical",
"important",
"security",
"performance",
"cost",
"hours"
]
}
```
See `.tdsrc.example.json` for a full example configuration.
## Resources
The server provides access to TDS resources through URIs:
### Guides Layer (Comments)
- URI: `tds://guides/{file_path}`
- Format: JSON array of TDS comments
- Example: `tds://guides/src/payment.js`
### Anchors Layer (Documents)
- URI: `tds://anchors/{file_path}`
- Format: Markdown content
- Example: `tds://anchors/integrations/payment-api.md`
### Patterns Layer (Documents)
- URI: `tds://patterns/{file_path}`
- Format: Markdown content
- Example: `tds://patterns/error-handling/retry-patterns.md`
## Development
### Project Structure
```
tds-mcp/
├── src/
│ └── index.ts # Main server implementation
├── build/ # Compiled output
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
└── README.md # This file
```
### Scripts
- `npm run build` - Compile TypeScript to JavaScript
- `npm run dev` - Run in development mode with hot reloading
- `npm start` - Run the compiled server
### Adding New Tools
To add new TDS tools:
1. Add the tool definition to the `ListToolsRequestSchema` handler
2. Add the tool implementation to the `CallToolRequestSchema` handler
3. Create the implementation function
Example:
```typescript
// In ListToolsRequestSchema handler
{
name: 'tds_new_tool',
description: 'Description of the new tool',
inputSchema: {
type: 'object',
properties: {
// Define parameters
}
}
}
// In CallToolRequestSchema handler
case 'tds_new_tool':
return await handleNewTool(args.param1, args.param2);
// Implementation function
async function handleNewTool(param1: string, param2: string) {
// Implementation
return {
content: [
{
type: 'text',
text: 'Tool result'
}
]
};
}
```
## Troubleshooting
### Common Issues
1. **Server won't start**: Check that all dependencies are installed with `npm install`
2. **No TDS comments found**: Ensure your code files contain properly formatted TDS comments
3. **Anchors not found**: Check that the `anchors/` directory exists and contains markdown files
4. **Patterns not found**: Check that the `patterns/` directory exists and contains markdown files
### Debug Mode
Run the server with debug output:
```bash
DEBUG=* npm run dev
```
### Logs
The server logs to stderr, so you can redirect output:
```bash
npm start 2> tds-mcp.log
```
## License
MIT License - see LICENSE file for details.
## Contributing
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests if applicable
5. Submit a pull request
## Support
For issues and questions:
- Check the [TDS documentation](../README.md)
- Review the [troubleshooting guide](#troubleshooting)
- Open an issue in the project repository
TDQS
Scored across 4 tools
tds_search and tds_get_context overlap conceptually, since both retrieve TDS knowledge, and their boundary depends on whether the agent supplies a query or a work context. tds_report and tds_promote are clearly distinct, but the search/context pair may cause misselection.
All tools use a consistent tds_ prefix, and most follow a simple tds_verb pattern. tds_get_context introduces a verb_noun form, which is a minor deviation but still readable and predictable.
Four tools is a focused, well-scoped surface for a knowledge-retrieval and promotion server. Each tool has a plausible distinct role, though the set is slightly thin for the apparent breadth of TDS layers.
The surface covers search, context retrieval, reporting, and promotion, but lacks lifecycle operations for guides, anchors, and patterns such as create, update, delete, or list. Agents cannot manage the underlying knowledge base beyond promoting a learning comment.