Sharpitect: Semantic C# Navigation
Overview
Sharpitect provides semantic understanding of C# codebases through MCP tools. Always prefer Sharpitect MCP tools over text-based searching (Grep/Glob) when working with C# code.
When to Use Sharpitect Tools
Use Sharpitect tools as your first choice for:
Finding Declarations
- Instead of:
Grep with pattern matching
- Use:
search_declarations to find classes, interfaces, methods, properties by name
- Benefits: Exact semantic matches, understands C# syntax, filters by declaration kind
Understanding Type Hierarchies
- Instead of: Reading class files and searching for base classes
- Use:
get_inheritance with direction: descendants (implementations) or ancestors (base types)
- Benefits: Complete hierarchy tree, includes interfaces and abstract classes
Finding Method/Property Usage
- Instead of:
Grep for method names (which may match strings, comments, etc.)
- Use:
get_callers to find what calls a method, or get_usages for all references
- Benefits: Accurate call sites only, no false positives from comments or strings
Understanding Dependencies
- Instead of: Reading code to find what a method calls
- Use:
get_callees to see all methods/properties a method uses
- Benefits: Complete dependency graph, includes transitive calls
Exploring Code Structure
- Instead of:
Glob to list files and Read to understand structure
- Use:
get_tree to see containment hierarchy, get_children for members
- Benefits: Semantic structure, filtered by kind, shows relationships
Finding Project Dependencies
- Instead of: Reading .csproj files or searching for using statements
- Use:
get_dependencies (what a project references) or get_dependents (what depends on a project)
- Benefits: Complete project graph, includes transitive dependencies
Tool Selection Guide
Use Sharpitect MCP tools for:
- Finding C# elements: Classes, methods, properties, interfaces
- Understanding relationships: Inheritance, calls, dependencies, usages
- Navigating structure: Hierarchies, containment, project organization
- Precise queries: "Find all implementations of IFoo"
Fall back to generic tools only when:
- Reading source code: Use
Read to see actual implementation
- Searching non-code content: Comments, strings, XML docs, config files
- Cross-language search: JavaScript, JSON, Markdown files
- Pattern matching: Complex regex patterns not supported by Sharpitect
Common Workflows
Workflow 1: "Find implementations of an interface"
1. search_declarations(query="IGraphRepository", kind="interface")
2. get_inheritance(id="...", direction="descendants")
Workflow 2: "Where is this method called?"
1. search_declarations(query="LoadGraph", kind="method")
2. get_callers(id="...", depth=1)
Workflow 3: "What does this class depend on?"
1. search_declarations(query="SqliteGraphRepository", kind="class")
2. get_relationships(id="...", relationshipKind="uses", direction="outgoing")
Workflow 4: "Show me all classes in a namespace"
1. search_declarations(query="Sharpitect.Analysis.Graph", kind="namespace")
2. get_children(id="...", kind="class")
Workflow 5: "Find all methods that call a specific method"
1. search_declarations(query="SaveNode", kind="method")
2. get_usages(id="...", usageKind="call")
Key Sharpitect Tools Reference
| Tool |
Purpose |
When to Use |
search_declarations |
Find declarations by name |
First step for finding any C# element |
get_inheritance |
Get type hierarchy |
Understanding class/interface relationships |
get_callers |
Find who calls a method |
Tracing method usage upstream |
get_callees |
Find what a method calls |
Understanding method dependencies |
get_usages |
Find all references |
Comprehensive usage analysis |
get_relationships |
Get all relationships |
Exploring complex relationships |
get_dependencies |
Project dependencies |
Understanding project references |
get_tree |
Containment hierarchy |
Exploring code structure |
get_signature |
Type/method signature |
Getting detailed type information |
get_file_declarations |
Declarations in a file |
Quick overview of file contents |
Important Notes
- Always use Sharpitect first: Even if you think Grep might work, try Sharpitect first
- Combine with Read: Use Sharpitect to find locations, then
Read to see implementation
- Be specific with kinds: Use
kind parameter to filter (class, interface, method, property, etc.)
- Use depth wisely: For
get_callers/get_callees, start with depth=1, increase if needed
- Check the database: If Sharpitect returns no results, the codebase may not be analyzed yet (run
sharpitect analyze)
Examples
❌ Don't do this:
Grep pattern="class.*IGraphRepository" to find implementations
✅ Do this instead:
1. search_declarations(query="IGraphRepository", kind="interface", matchMode="exact")
2. get_inheritance(id="...", direction="descendants")
❌ Don't do this:
Grep pattern="LoadGraph\\(" to find method calls
✅ Do this instead:
1. search_declarations(query="LoadGraph", kind="method")
2. get_callers(id="...")
❌ Don't do this:
Read all files in a namespace to understand structure
✅ Do this instead:
1. search_declarations(query="Sharpitect.Analysis", kind="namespace")
2. get_tree(rootId="...", maxDepth=2)
Summary
When working with C# code, think "Sharpitect first, generic tools second." Sharpitect understands C# semantics and provides accurate, efficient navigation. Only fall back to Grep/Glob/Read when you need non-semantic searches or actual source code content.
1---2name: use-sharpitect3description: Navigate and analyze C# codebases using Sharpitect's semantic tools. Use when searching for C# declarations, understanding inheritance, finding method callers/callees, or exploring code relationships in .NET projects.4---5
6# Sharpitect: Semantic C# Navigation
7
8## Overview
9
10Sharpitect provides semantic understanding of C# codebases through MCP tools. **Always prefer Sharpitect MCP tools over text-based searching (Grep/Glob) when working with C# code.**
11
12## When to Use Sharpitect Tools
13
14Use Sharpitect tools as your **first choice** for:
15
16### Finding Declarations
17- **Instead of**: `Grep` with pattern matching
18- **Use**: `search_declarations` to find classes, interfaces, methods, properties by name
19- **Benefits**: Exact semantic matches, understands C# syntax, filters by declaration kind
20
21### Understanding Type Hierarchies
22- **Instead of**: Reading class files and searching for base classes
23- **Use**: `get_inheritance` with `direction: descendants` (implementations) or `ancestors` (base types)
24- **Benefits**: Complete hierarchy tree, includes interfaces and abstract classes
25
26### Finding Method/Property Usage
27- **Instead of**: `Grep` for method names (which may match strings, comments, etc.)
28- **Use**: `get_callers` to find what calls a method, or `get_usages` for all references
29- **Benefits**: Accurate call sites only, no false positives from comments or strings
30
31### Understanding Dependencies
32- **Instead of**: Reading code to find what a method calls
33- **Use**: `get_callees` to see all methods/properties a method uses
34- **Benefits**: Complete dependency graph, includes transitive calls
35
36### Exploring Code Structure
37- **Instead of**: `Glob` to list files and `Read` to understand structure
38- **Use**: `get_tree` to see containment hierarchy, `get_children` for members
39- **Benefits**: Semantic structure, filtered by kind, shows relationships
40
41### Finding Project Dependencies
42- **Instead of**: Reading .csproj files or searching for using statements
43- **Use**: `get_dependencies` (what a project references) or `get_dependents` (what depends on a project)
44- **Benefits**: Complete project graph, includes transitive dependencies
45
46## Tool Selection Guide
47
48### Use Sharpitect MCP tools for:
491. **Finding C# elements**: Classes, methods, properties, interfaces
502. **Understanding relationships**: Inheritance, calls, dependencies, usages
513. **Navigating structure**: Hierarchies, containment, project organization
524. **Precise queries**: "Find all implementations of IFoo"
53
54### Fall back to generic tools only when:
551. **Reading source code**: Use `Read` to see actual implementation
562. **Searching non-code content**: Comments, strings, XML docs, config files
573. **Cross-language search**: JavaScript, JSON, Markdown files
584. **Pattern matching**: Complex regex patterns not supported by Sharpitect
59
60## Common Workflows
61
62### Workflow 1: "Find implementations of an interface"
63```
641. search_declarations(query="IGraphRepository", kind="interface")
652. get_inheritance(id="...", direction="descendants")
66```
67
68### Workflow 2: "Where is this method called?"
69```
701. search_declarations(query="LoadGraph", kind="method")
712. get_callers(id="...", depth=1)
72```
73
74### Workflow 3: "What does this class depend on?"
75```
761. search_declarations(query="SqliteGraphRepository", kind="class")
772. get_relationships(id="...", relationshipKind="uses", direction="outgoing")
78```
79
80### Workflow 4: "Show me all classes in a namespace"
81```
821. search_declarations(query="Sharpitect.Analysis.Graph", kind="namespace")
832. get_children(id="...", kind="class")
84```
85
86### Workflow 5: "Find all methods that call a specific method"
87```
881. search_declarations(query="SaveNode", kind="method")
892. get_usages(id="...", usageKind="call")
90```
91
92## Key Sharpitect Tools Reference
93
94| Tool | Purpose | When to Use |
95|------|---------|-------------|
96| `search_declarations` | Find declarations by name | First step for finding any C# element |
97| `get_inheritance` | Get type hierarchy | Understanding class/interface relationships |
98| `get_callers` | Find who calls a method | Tracing method usage upstream |
99| `get_callees` | Find what a method calls | Understanding method dependencies |
100| `get_usages` | Find all references | Comprehensive usage analysis |
101| `get_relationships` | Get all relationships | Exploring complex relationships |
102| `get_dependencies` | Project dependencies | Understanding project references |
103| `get_tree` | Containment hierarchy | Exploring code structure |
104| `get_signature` | Type/method signature | Getting detailed type information |
105| `get_file_declarations` | Declarations in a file | Quick overview of file contents |
106
107## Important Notes
108
109- **Always use Sharpitect first**: Even if you think Grep might work, try Sharpitect first
110- **Combine with Read**: Use Sharpitect to find locations, then `Read` to see implementation
111- **Be specific with kinds**: Use `kind` parameter to filter (class, interface, method, property, etc.)
112- **Use depth wisely**: For `get_callers`/`get_callees`, start with depth=1, increase if needed
113- **Check the database**: If Sharpitect returns no results, the codebase may not be analyzed yet (run `sharpitect analyze`)
114
115## Examples
116
117### ❌ Don't do this:
118```
119Grep pattern="class.*IGraphRepository" to find implementations
120```
121
122### ✅ Do this instead:
123```
1241. search_declarations(query="IGraphRepository", kind="interface", matchMode="exact")
1252. get_inheritance(id="...", direction="descendants")
126```
127
128---
129
130### ❌ Don't do this:
131```
132Grep pattern="LoadGraph\\(" to find method calls
133```
134
135### ✅ Do this instead:
136```
1371. search_declarations(query="LoadGraph", kind="method")
1382. get_callers(id="...")
139```
140
141---
142
143### ❌ Don't do this:
144```
145Read all files in a namespace to understand structure
146```
147
148### ✅ Do this instead:
149```
1501. search_declarations(query="Sharpitect.Analysis", kind="namespace")
1512. get_tree(rootId="...", maxDepth=2)
152```
153
154## Summary
155
156**When working with C# code, think "Sharpitect first, generic tools second."** Sharpitect understands C# semantics and provides accurate, efficient navigation. Only fall back to Grep/Glob/Read when you need non-semantic searches or actual source code content.