# Exact Type Inference Validator MCP for AI Agents MCP

> Exact Type Inference Validator MCP for analyzing TypeScript source code. It identifies implicit 'any' types, unsafe type assertions, and unannotated declarations to help you maintain strict type safety standards across your entire codebase.

## Overview
- **Category:** productivity
- **Price:** Free
- **Endpoint:** https://edge.vinkius.com/vk_preview_SjkYsHYSQxbXiIPBY5DbQf5Oyt4LUozVC5CATknr/mcp
- **Tags:** typescript, static-analysis, type-safety, code-quality, linting

## Description

You spend hours writing TypeScript, only to realize a sneaky type assertion or an unannotated variable just introduced a runtime error. This MCP lets your AI agent act as a dedicated code auditor. It scans your files to find exactly where your types are weak or missing. Instead of manually hunting through pull requests, you can ask your agent to check for safety violations or calculate a precise score for your codebase's health. By connecting this to the Vinkius catalog, you give your coding assistant the eyes it needs to enforce strict standards automatically. It turns code reviews from a manual search into an automated verification process.

## Prompt Examples

**Prompt:** 
```
Is this new code safe?
```

**Response:** 
```
The code snippet contains safety issues:

| Issue Type | Location |
| :--- | :--- |
| **Unsafe Assertion** | Line 4: `as any` |
| **Implicit Any** | Line 12: `param` |

I recommend adding explicit types to prevent runtime errors.
```

**Prompt:** 
```
How much of my project is properly typed?
```

**Response:** 
```
Your current type coverage is **64%**. 

* **Annotated Nodes:** 128
* **Unannotated Nodes:** 71

Focusing on the `src/services` directory would yield the highest improvement.
```

**Prompt:** 
```
Find all the unsafe casts in src/utils.ts
```

**Response:** 
```
I found 3 unsafe type assertions in `src/utils.ts`:

1. **Line 22**: `const data = input as string;` 
2. **Line 45**: `return result as User;` 
3. **Line 89**: `const config = settings as any;`
```

## Capabilities

### Identify unannotated variables
Finds every declaration that lacks an explicit type annotation.

### Detect unsafe type assertions
Locates instances where the 'as' keyword is used to bypass the compiler.

### Find implicit any usage
Scans for variables that default to the 'any' type without being explicitly declared.

### Calculate codebase safety scores
Generates a numerical metric representing your project's overall type health.

### Audit type coverage
Provides a detailed report on which parts of your source code are properly typed.

## Use Cases

### Catching sneaky PR errors
A developer submits a PR with an 'as any' cast. The agent uses get_unsafe_usage to flag it immediately during the review.

### Measuring migration progress
You are moving from JS to TS. Ask your agent to use get_type_coverage to see how much of the legacy code is still unannotated.

### Enforcing team standards
A lead wants to ensure no new unannotated variables are added. The agent runs calculate_safety_metrics on every new commit.

### Auditing third-party code
You have pulled in a new library. Your agent scans it with get_type_coverage to see if the types are actually reliable.

## Benefits

- Stop runtime crashes by finding implicit 'any' usage before they reach production.
- Maintain high standards using calculate_safety_metrics to track code health over time.
- Automate code reviews by having your agent check for unsafe casts with get_unsafe_usage.
- Improve documentation quality by identifying unannotated nodes via get_type_coverage.
- Reduce technical debt by quantifying type safety gaps across your entire repository.

## How It Works

The bottom line is you get an automated way to enforce strict TypeScript rules without manual inspection.

1. Connect the MCP to your preferred AI client like Cursor or Windsurf.
2. Point your agent toward your TypeScript source directory.
3. Ask for a safety audit or specific coverage metrics.

## Frequently Asked Questions

**How can I use Exact Type Inference Validator to find bugs?**
It scans your TypeScript files for implicit 'any' types and unsafe assertions that could cause runtime crashes.

**Does Exact Type Inference Validator work with Cursor?**
Yes, it works with any MCP-compatible client, including Cursor, Windsurf, and VS Code.

**Can Exact Type Inference Validator help with TypeScript migrations?**
Absolutely. It tracks your coverage progress so you can see exactly how much of your legacy code is now properly typed.

**How do I know if my code is type-safe using this MCP?**
The tool generates a numerical safety score that quantifies the strictness and health of your types.

**Does the Exact Type Inference Validator check for 'as any' usage?**
Yes, it specifically identifies every instance where you use unsafe type assertions to bypass the compiler.

**What does it mean if my code is not type safe?**
It means the validator found unannotated variables or unsafe patterns like `as` assertions and explicit `any` usage. Tools available: `your_tool_name`.

**How is the Type Safety Score calculated?**
The score is computed by taking the total number of declarations and subtracting unannotated nodes and unsafe patterns, then dividing by the total count.

**Can I use this to find implicit 'any' in my functions?**
Yes, the `get_type_coverage` tool specifically identifies function parameters and declarations that lack type annotations.