Skip to content

Add support for JS/TS entry point detection for LLMs#1

Merged
vinmay merged 1 commit intomainfrom
js-ts-entry-point-detection
Feb 28, 2026
Merged

Add support for JS/TS entry point detection for LLMs#1
vinmay merged 1 commit intomainfrom
js-ts-entry-point-detection

Conversation

@vinmay
Copy link
Owner

@vinmay vinmay commented Feb 28, 2026

TypeScript/JavaScript Entry Point Detection

Added src/agent_scan/ts_entry_points.py — a new module that detects LLM-callable functions in TypeScript and JavaScript source files using regex-based
pattern matching, without requiring a Node.js runtime. Wired into scanner.py and text_reporter.py so results appear in every scan.

Four detection patterns are covered:

  • mcp_tool — server.tool("name", schema, handler) — the standard MCP SDK registration call, both inline and multi-line (where the name is on the line
    after the opening parenthesis)
  • mcp_handler — server.setRequestHandler(Schema, handler) — MCP request handler registration, both inline and multi-line
  • mcp_tool_definition — { name: "...", description: ..., inputSchema: ... } — the canonical MCP tool object format, used when tools are defined as typed
    schema objects (Zod ToolSchema<> pattern) or returned as arrays from a factory function
  • langchain_tool — new DynamicTool({ name: "...", ... }) — LangChain.js tool registration, both inline and multi-line

File filtering skips node_modules, dist, build, .d.ts declaration files, .test.ts/.spec.ts files, and .min.js bundles. The multi-line variants for
server.tool( and setRequestHandler( use a strict 1-line lookahead — if the first argument isn't a string literal on the very next line, it's treated as
dynamic and skipped, which prevents picking up description strings as tool names.

Validated against 8 real-world TypeScript MCP repos: exa-mcp-server (9 tools), mcp-server-cloudflare (122 tools across a monorepo), mcp-server-browserbase
(9 tools), mcp-playwright (33 tools), tavily-mcp (5 tools). No false positives found in spot-checking the full 122-entry cloudflare results.


Unsupported Language Detection

When a scan finds no Python or TypeScript files, the report now detects what languages are actually present and names them. A map of 28 languages (Go,
Rust, Ruby, Java, Kotlin, Scala, C#, C++, Swift, Elixir, and more) is checked against file extensions, with standard noise directories excluded. The
output looks like:

No Python or TypeScript files were found for analysis.
Detected: Go (146 files)
agent-scan currently supports Python (full analysis) and TypeScript (entry points).

Previously the message was the same whether you scanned a Go repo or an empty directory. Now it's actionable.

@vinmay vinmay merged commit 6fe2410 into main Feb 28, 2026
2 checks passed
@vinmay vinmay deleted the js-ts-entry-point-detection branch March 1, 2026 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant