nia-mcp-server 1.0.6__py3-none-any.whl → 1.0.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of nia-mcp-server might be problematic. Click here for more details.
- nia_mcp_server/__init__.py +1 -1
- nia_mcp_server/api_client.py +4 -2
- nia_mcp_server/assets/rules/claude_rules.md +270 -0
- nia_mcp_server/assets/rules/cursor_rules.md +64 -0
- nia_mcp_server/assets/rules/nia_rules.md +149 -0
- nia_mcp_server/assets/rules/vscode_rules.md +312 -0
- nia_mcp_server/assets/rules/windsurf_rules.md +92 -0
- nia_mcp_server/project_init.py +1 -1
- nia_mcp_server/server.py +159 -0
- {nia_mcp_server-1.0.6.dist-info → nia_mcp_server-1.0.8.dist-info}/METADATA +6 -8
- nia_mcp_server-1.0.8.dist-info/RECORD +16 -0
- nia_mcp_server-1.0.8.dist-info/licenses/LICENSE +31 -0
- nia_mcp_server-1.0.6.dist-info/RECORD +0 -12
- nia_mcp_server-1.0.6.dist-info/entry_points.txt +0 -2
- nia_mcp_server-1.0.6.dist-info/licenses/LICENSE +0 -21
- {nia_mcp_server-1.0.6.dist-info → nia_mcp_server-1.0.8.dist-info}/WHEEL +0 -0
nia_mcp_server/__init__.py
CHANGED
nia_mcp_server/api_client.py
CHANGED
|
@@ -24,7 +24,7 @@ class NIAApiClient:
|
|
|
24
24
|
def __init__(self, api_key: str, base_url: str = None):
|
|
25
25
|
self.api_key = api_key
|
|
26
26
|
# Remove trailing slash from base URL to prevent double slashes
|
|
27
|
-
self.base_url = (base_url or os.getenv("NIA_API_URL", "https://
|
|
27
|
+
self.base_url = (base_url or os.getenv("NIA_API_URL", "https://apigcp.trynia.ai")).rstrip('/')
|
|
28
28
|
self.client = httpx.AsyncClient(
|
|
29
29
|
headers={
|
|
30
30
|
"Authorization": f"Bearer {api_key}",
|
|
@@ -400,6 +400,7 @@ class NIAApiClient:
|
|
|
400
400
|
self,
|
|
401
401
|
url: str,
|
|
402
402
|
url_patterns: List[str] = None,
|
|
403
|
+
exclude_patterns: List[str] = None,
|
|
403
404
|
max_age: int = None,
|
|
404
405
|
only_main_content: bool = True
|
|
405
406
|
) -> Dict[str, Any]:
|
|
@@ -407,7 +408,8 @@ class NIAApiClient:
|
|
|
407
408
|
try:
|
|
408
409
|
payload = {
|
|
409
410
|
"url": url,
|
|
410
|
-
"url_patterns": url_patterns or []
|
|
411
|
+
"url_patterns": url_patterns or [],
|
|
412
|
+
"exclude_patterns": exclude_patterns or []
|
|
411
413
|
}
|
|
412
414
|
|
|
413
415
|
# Add optional parameters
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
# Nia Integration for Claude Desktop
|
|
2
|
+
|
|
3
|
+
## Claude Desktop Configuration
|
|
4
|
+
|
|
5
|
+
### 1. Project Structure
|
|
6
|
+
When Nia is initialized for Claude Desktop, it creates:
|
|
7
|
+
```
|
|
8
|
+
.claude/
|
|
9
|
+
├── nia_config.json # Nia-specific settings
|
|
10
|
+
├── indexed_repos.json # Tracked repositories
|
|
11
|
+
└── search_patterns.json # Common search patterns
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### 2. Configuration File
|
|
15
|
+
Create `.claude/nia_config.json`:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"version": "1.0",
|
|
20
|
+
"defaultBehavior": {
|
|
21
|
+
"autoSuggestIndexing": true,
|
|
22
|
+
"includeSourcesInResponse": true,
|
|
23
|
+
"searchResultLimit": 5,
|
|
24
|
+
"deepResearchTimeout": 300
|
|
25
|
+
},
|
|
26
|
+
"searchPatterns": {
|
|
27
|
+
"architecture": "How is {feature} architected in {repo}?",
|
|
28
|
+
"implementation": "Show me the implementation of {feature}",
|
|
29
|
+
"patterns": "What patterns are used for {concern}?",
|
|
30
|
+
"debugging": "Find similar issues to {error}"
|
|
31
|
+
},
|
|
32
|
+
"workspaceRepos": [],
|
|
33
|
+
"frequentSearches": []
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Claude-Specific Interaction Patterns
|
|
38
|
+
|
|
39
|
+
### 1. Conversational Flow
|
|
40
|
+
Claude should maintain context naturally:
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
User: "I'm working on a RAG implementation"
|
|
44
|
+
Claude: I'll help you with RAG implementation. Let me search for the best examples and patterns.
|
|
45
|
+
[Runs: nia_web_search "RAG implementation examples production ready"]
|
|
46
|
+
|
|
47
|
+
I found several excellent RAG implementations. Would you like me to:
|
|
48
|
+
1. Index these repositories for detailed analysis
|
|
49
|
+
2. Compare different approaches
|
|
50
|
+
3. Search for specific features you need
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 2. Proactive Assistance
|
|
54
|
+
Anticipate user needs:
|
|
55
|
+
|
|
56
|
+
- When user mentions a GitHub URL → Suggest indexing
|
|
57
|
+
- When user asks about code → Check if repo is indexed first
|
|
58
|
+
- When comparing options → Use deep research agent
|
|
59
|
+
- When debugging → Search for similar issues
|
|
60
|
+
|
|
61
|
+
### 3. Context-Aware Responses
|
|
62
|
+
Maintain conversation context:
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
First message: User asks about authentication
|
|
66
|
+
- Check indexed repos for auth implementations
|
|
67
|
+
- Remember this context for follow-ups
|
|
68
|
+
|
|
69
|
+
Second message: User asks "how about the middleware?"
|
|
70
|
+
- Know they mean auth middleware
|
|
71
|
+
- Search specifically for middleware in auth context
|
|
72
|
+
- Reference previous findings
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Claude Desktop Workflows
|
|
76
|
+
|
|
77
|
+
### 1. Project Understanding
|
|
78
|
+
```markdown
|
|
79
|
+
When user opens a new project:
|
|
80
|
+
1. Detect project type from files
|
|
81
|
+
2. Suggest indexing the repository
|
|
82
|
+
3. Offer to index related dependencies
|
|
83
|
+
4. Provide architecture overview
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 2. Code Generation
|
|
87
|
+
```markdown
|
|
88
|
+
When generating code:
|
|
89
|
+
1. Search indexed repos for patterns
|
|
90
|
+
2. Use found examples as reference
|
|
91
|
+
3. Adapt to project's style
|
|
92
|
+
4. Cite sources for transparency
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### 3. Problem Solving
|
|
96
|
+
```markdown
|
|
97
|
+
When solving issues:
|
|
98
|
+
1. Search for error messages
|
|
99
|
+
2. Find similar problems and solutions
|
|
100
|
+
3. Understand the context
|
|
101
|
+
4. Provide step-by-step fixes
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### 4. Learning & Teaching
|
|
105
|
+
```markdown
|
|
106
|
+
When explaining concepts:
|
|
107
|
+
1. Use deep research for comprehensive overview
|
|
108
|
+
2. Find real-world examples in indexed repos
|
|
109
|
+
3. Show implementation variations
|
|
110
|
+
4. Explain trade-offs with evidence
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Response Formatting for Claude
|
|
114
|
+
|
|
115
|
+
### 1. Search Results Presentation
|
|
116
|
+
```markdown
|
|
117
|
+
## 🔍 Found in indexed repositories:
|
|
118
|
+
|
|
119
|
+
**Authentication Implementation** (nextjs-app-template)
|
|
120
|
+
- 📁 `middleware.ts:23-45` - Route protection
|
|
121
|
+
- 📁 `lib/auth/session.ts:12-89` - Session management
|
|
122
|
+
- 📁 `app/api/auth/route.ts:5-34` - API endpoints
|
|
123
|
+
|
|
124
|
+
**Key Pattern:** Uses NextAuth with JWT strategy
|
|
125
|
+
[Show relevant code snippet]
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### 2. Code Examples
|
|
129
|
+
Always provide context:
|
|
130
|
+
```typescript
|
|
131
|
+
// From: awesome-saas-starter/lib/auth/session.ts
|
|
132
|
+
// This pattern handles refresh tokens elegantly
|
|
133
|
+
export async function refreshSession(token: string) {
|
|
134
|
+
// ... implementation
|
|
135
|
+
}
|
|
136
|
+
// Note: This repo uses Redis for session storage
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### 3. Comparative Analysis
|
|
140
|
+
Structure comparisons clearly:
|
|
141
|
+
```markdown
|
|
142
|
+
## Comparison: Prisma vs Drizzle ORM
|
|
143
|
+
|
|
144
|
+
Based on analysis of 15 production repositories:
|
|
145
|
+
|
|
146
|
+
| Aspect | Prisma | Drizzle |
|
|
147
|
+
|--------|--------|---------|
|
|
148
|
+
| Type Safety | Excellent (generated) | Excellent (inferred) |
|
|
149
|
+
| Performance | Good | Better |
|
|
150
|
+
| Learning Curve | Gentle | Steeper |
|
|
151
|
+
|
|
152
|
+
**Recommendation:** [Based on your use case...]
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Advanced Claude Behaviors
|
|
156
|
+
|
|
157
|
+
### 1. Multi-Step Research
|
|
158
|
+
For complex questions:
|
|
159
|
+
```
|
|
160
|
+
Step 1: Use nia_deep_research_agent for overview
|
|
161
|
+
Step 2: Use nia_web_search for specific examples
|
|
162
|
+
Step 3: Index discovered repositories
|
|
163
|
+
Step 4: Search indexed repos for details
|
|
164
|
+
Step 5: Synthesize findings with citations
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### 2. Intelligent Caching
|
|
168
|
+
Remember within conversation:
|
|
169
|
+
- Previously indexed repositories
|
|
170
|
+
- Search results from earlier queries
|
|
171
|
+
- User's project context
|
|
172
|
+
- Technical preferences
|
|
173
|
+
|
|
174
|
+
### 3. Error Recovery
|
|
175
|
+
Handle failures gracefully:
|
|
176
|
+
```
|
|
177
|
+
If indexing fails:
|
|
178
|
+
- Explain the issue clearly
|
|
179
|
+
- Suggest alternatives
|
|
180
|
+
- Offer to try again later
|
|
181
|
+
- Provide manual workarounds
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### 4. Documentation Indexing
|
|
185
|
+
When users want to index documentation:
|
|
186
|
+
```
|
|
187
|
+
If user provides just a URL:
|
|
188
|
+
- Default to indexing entire site with ["/*"]
|
|
189
|
+
- Or ask: "Should I index the entire documentation or specific sections?"
|
|
190
|
+
- Suggest common patterns: ["/docs/*", "/api/*", "/guide/*"]
|
|
191
|
+
- Example: index_documentation "https://docs.example.com" ["/*"]
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Claude-Specific Commands
|
|
195
|
+
|
|
196
|
+
### Quick Actions
|
|
197
|
+
Recognize these patterns:
|
|
198
|
+
|
|
199
|
+
- "Index this" → Index current repository
|
|
200
|
+
- "Search for X" → Use appropriate search tool
|
|
201
|
+
- "Compare X and Y" → Use deep research
|
|
202
|
+
- "Find examples" → Web search then index
|
|
203
|
+
- "Explain this code" → Search for patterns
|
|
204
|
+
|
|
205
|
+
### Batch Operations
|
|
206
|
+
Handle multiple requests:
|
|
207
|
+
```
|
|
208
|
+
User: "Index these repos: A, B, C and then compare their auth systems"
|
|
209
|
+
Claude: I'll index all three repositories and then analyze their authentication approaches.
|
|
210
|
+
[Runs multiple index_repository commands]
|
|
211
|
+
[Waits for completion]
|
|
212
|
+
[Runs search_codebase for auth patterns]
|
|
213
|
+
[Provides comparative analysis]
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Best Practices for Claude
|
|
217
|
+
|
|
218
|
+
### 1. Natural Language
|
|
219
|
+
- Maintain conversational tone
|
|
220
|
+
- Explain technical concepts clearly
|
|
221
|
+
- Use analogies when helpful
|
|
222
|
+
- Avoid jargon unless necessary
|
|
223
|
+
|
|
224
|
+
### 2. Progressive Disclosure
|
|
225
|
+
- Start with overview
|
|
226
|
+
- Provide details on request
|
|
227
|
+
- Link to deeper resources
|
|
228
|
+
- Offer next steps
|
|
229
|
+
|
|
230
|
+
### 3. Source Attribution
|
|
231
|
+
- Always cite repositories
|
|
232
|
+
- Include file paths and line numbers
|
|
233
|
+
- Link to specific commits when relevant
|
|
234
|
+
- Credit original authors
|
|
235
|
+
|
|
236
|
+
### 4. Learning from Interaction
|
|
237
|
+
- Note user preferences
|
|
238
|
+
- Adapt search queries based on feedback
|
|
239
|
+
- Refine suggestions over time
|
|
240
|
+
- Build on previous conversations
|
|
241
|
+
|
|
242
|
+
## Example Interactions
|
|
243
|
+
|
|
244
|
+
### Architecture Understanding
|
|
245
|
+
```
|
|
246
|
+
User: "How does Vercel handle serverless functions?"
|
|
247
|
+
Claude: I'll research how Vercel implements serverless functions.
|
|
248
|
+
|
|
249
|
+
[Runs: nia_deep_research_agent "Vercel serverless functions architecture implementation"]
|
|
250
|
+
|
|
251
|
+
Based on my research, Vercel's serverless architecture... [comprehensive explanation]
|
|
252
|
+
|
|
253
|
+
I found several open-source projects that demonstrate this. Shall I index them for deeper analysis?
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Code Pattern Search
|
|
257
|
+
```
|
|
258
|
+
User: "Show me good examples of React Server Components"
|
|
259
|
+
Claude: I'll search for production-ready React Server Components examples.
|
|
260
|
+
|
|
261
|
+
[Runs: nia_web_search "React Server Components production examples 2024"]
|
|
262
|
+
|
|
263
|
+
I found 5 excellent repositories using RSC. Let me index the most relevant one:
|
|
264
|
+
|
|
265
|
+
[Runs: index_repository https://github.com/vercel/next-app-router-playground]
|
|
266
|
+
|
|
267
|
+
Now I can show you specific patterns... [detailed examples]
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Remember: Make Nia's capabilities feel like a natural extension of Claude's knowledge!
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Nia MCP Tool Usage Guide
|
|
2
|
+
|
|
3
|
+
Note: Nia is just "Nia" - not an acronym or "Neural Intelligent Assistant".
|
|
4
|
+
|
|
5
|
+
## When to use each tool:
|
|
6
|
+
|
|
7
|
+
### `list_repositories`
|
|
8
|
+
Use when:
|
|
9
|
+
- User asks what repos are available/indexed
|
|
10
|
+
- Before searching to verify repo is indexed
|
|
11
|
+
- User wants to see their indexed codebase list
|
|
12
|
+
|
|
13
|
+
### `index_repository`
|
|
14
|
+
Use when:
|
|
15
|
+
- User mentions a GitHub URL
|
|
16
|
+
- User wants to analyze a specific codebase
|
|
17
|
+
- Before searching a new repository
|
|
18
|
+
|
|
19
|
+
### `search_codebase`
|
|
20
|
+
Use when:
|
|
21
|
+
- User asks how something works in code
|
|
22
|
+
- User wants to find specific implementations
|
|
23
|
+
- User needs to understand code patterns
|
|
24
|
+
- Searching within indexed repositories only
|
|
25
|
+
|
|
26
|
+
### `search_documentation`
|
|
27
|
+
Use when:
|
|
28
|
+
- User asks about documentation
|
|
29
|
+
- Looking for API references
|
|
30
|
+
- Searching indexed documentation sites
|
|
31
|
+
|
|
32
|
+
### `nia_web_search`
|
|
33
|
+
Use when:
|
|
34
|
+
- Finding new repositories to index
|
|
35
|
+
- Quick discovery of libraries/frameworks
|
|
36
|
+
- Simple, direct searches
|
|
37
|
+
- Looking for trending content
|
|
38
|
+
|
|
39
|
+
### `nia_deep_research_agent`
|
|
40
|
+
Use when:
|
|
41
|
+
- Comparing multiple options (X vs Y)
|
|
42
|
+
- Need structured analysis
|
|
43
|
+
- Complex questions requiring synthesis
|
|
44
|
+
- Evaluating pros/cons
|
|
45
|
+
|
|
46
|
+
### `check_repository_status`
|
|
47
|
+
Use when:
|
|
48
|
+
- After starting indexing
|
|
49
|
+
- User asks about indexing progress
|
|
50
|
+
- Verifying if indexing completed
|
|
51
|
+
|
|
52
|
+
### `index_documentation`
|
|
53
|
+
Use when:
|
|
54
|
+
- User wants to index documentation sites
|
|
55
|
+
- User provides a documentation URL
|
|
56
|
+
|
|
57
|
+
**Important**: If user doesn't specify URL patterns:
|
|
58
|
+
- Default to `["/*"]` to index entire site
|
|
59
|
+
- Or ask: "Should I index the entire documentation or specific sections?"
|
|
60
|
+
- Common patterns: `["/docs/*", "/api/*", "/guide/*"]`
|
|
61
|
+
|
|
62
|
+
### Other tools:
|
|
63
|
+
- `delete_repository` - Remove indexed repo
|
|
64
|
+
- `initialize_project` - Set up Nia rules in project
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Nia Knowledge Agent Integration Rules
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
These rules guide AI assistants in effectively using Nia's knowledge search capabilities for codebase analysis, documentation search, and AI-powered research.
|
|
5
|
+
|
|
6
|
+
Note: Nia is just "Nia" - not an acronym. It's the name of the knowledge search platform.
|
|
7
|
+
|
|
8
|
+
## Core Principles
|
|
9
|
+
|
|
10
|
+
### 1. Repository Management
|
|
11
|
+
- **Always check indexed repositories** before searching with `list_repositories`
|
|
12
|
+
- **Proactively suggest indexing** when users mention GitHub repositories
|
|
13
|
+
- **Monitor indexing status** using `check_repository_status` for ongoing operations
|
|
14
|
+
- **Index relevant repositories** discovered during web searches
|
|
15
|
+
|
|
16
|
+
### 2. Search Strategy Selection
|
|
17
|
+
|
|
18
|
+
#### Use `nia_web_search` for:
|
|
19
|
+
- Finding specific repositories or documentation
|
|
20
|
+
- Quick lookups and discovery tasks
|
|
21
|
+
- Trending content searches
|
|
22
|
+
- Finding similar content to a known URL
|
|
23
|
+
- Simple, direct queries
|
|
24
|
+
|
|
25
|
+
#### Use `nia_deep_research_agent` for:
|
|
26
|
+
- Comparative analysis (X vs Y vs Z)
|
|
27
|
+
- Evaluating pros and cons
|
|
28
|
+
- Complex questions requiring synthesis
|
|
29
|
+
- Structured output needs (tables, lists)
|
|
30
|
+
- Questions with "best", "which is better", "compare"
|
|
31
|
+
|
|
32
|
+
### 3. Query Optimization
|
|
33
|
+
- **Use natural language queries** - Form complete questions, not just keywords
|
|
34
|
+
- **Be specific and detailed** - "How does authentication work in NextAuth.js?" not "auth nextauth"
|
|
35
|
+
- **Include context** - Mention specific technologies, frameworks, or use cases
|
|
36
|
+
- **Leverage repository context** - Specify repositories when searching indexed codebases
|
|
37
|
+
|
|
38
|
+
### 4. API Usage Best Practices
|
|
39
|
+
- **Handle rate limits gracefully** - Free tier has 25 API request limit
|
|
40
|
+
- **Cache results mentally** - Avoid redundant searches in the same conversation
|
|
41
|
+
- **Batch operations** - Index multiple related repositories together
|
|
42
|
+
- **Monitor status efficiently** - Check status periodically, not continuously
|
|
43
|
+
|
|
44
|
+
### 5. Result Interpretation
|
|
45
|
+
- **Provide actionable next steps** - Always suggest how to use the results
|
|
46
|
+
- **Extract indexable content** - Identify repositories and docs from search results
|
|
47
|
+
- **Format for readability** - Use markdown formatting for clear presentation
|
|
48
|
+
- **Include sources** - Always show where information comes from
|
|
49
|
+
|
|
50
|
+
### 6. Error Handling
|
|
51
|
+
- **Explain API limits clearly** - Help users understand free tier limitations
|
|
52
|
+
- **Suggest alternatives** - Provide workarounds when hitting limits
|
|
53
|
+
- **Report issues helpfully** - Include enough context for debugging
|
|
54
|
+
- **Guide to solutions** - Link to upgrade options when appropriate
|
|
55
|
+
|
|
56
|
+
## Workflow Patterns
|
|
57
|
+
|
|
58
|
+
### Pattern 1: New Project Research
|
|
59
|
+
1. Use `nia_deep_research_agent` to understand the technology landscape
|
|
60
|
+
2. Use `nia_web_search` to find specific implementations
|
|
61
|
+
3. Index discovered repositories for detailed analysis
|
|
62
|
+
4. Search indexed codebases for implementation details
|
|
63
|
+
|
|
64
|
+
### Pattern 2: Codebase Understanding
|
|
65
|
+
1. Check if repository is already indexed with `list_repositories`
|
|
66
|
+
2. If not indexed, use `index_repository` and wait for completion
|
|
67
|
+
3. Use `search_codebase` with specific technical questions
|
|
68
|
+
4. Include code snippets and file references in responses
|
|
69
|
+
|
|
70
|
+
### Pattern 3: Documentation Search
|
|
71
|
+
1. Index documentation sites with `index_documentation`
|
|
72
|
+
- If no URL patterns specified, default to `["/*"]` for entire site
|
|
73
|
+
- Or ask user: "Which sections should I index? (e.g., /docs/*, /api/*, or /* for everything)"
|
|
74
|
+
- Common patterns: `["/docs/*", "/api/*", "/guide/*", "/reference/*"]`
|
|
75
|
+
2. Use URL patterns to focus on relevant sections
|
|
76
|
+
3. Search with `search_documentation` for specific topics
|
|
77
|
+
4. Combine with code searches for complete understanding
|
|
78
|
+
|
|
79
|
+
### Pattern 4: Technology Comparison
|
|
80
|
+
1. Start with `nia_deep_research_agent` for structured comparison
|
|
81
|
+
2. Follow up with `nia_web_search` for specific examples
|
|
82
|
+
3. Index key repositories from each option
|
|
83
|
+
4. Search codebases to understand implementation differences
|
|
84
|
+
|
|
85
|
+
## Configuration
|
|
86
|
+
|
|
87
|
+
### Environment Setup
|
|
88
|
+
- **API Key**: Set `NIA_API_KEY` environment variable
|
|
89
|
+
- **Never hardcode API keys** in code or configuration files
|
|
90
|
+
- **Use .env files** for local development
|
|
91
|
+
- **Secure key storage** in production environments
|
|
92
|
+
|
|
93
|
+
### Project Structure
|
|
94
|
+
When initialized, Nia projects should have:
|
|
95
|
+
```
|
|
96
|
+
.nia/
|
|
97
|
+
├── config.json # Project-specific settings
|
|
98
|
+
├── indexed_repos.json # Track indexed repositories
|
|
99
|
+
└── search_history.json # Cache common queries
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Integration Guidelines
|
|
103
|
+
|
|
104
|
+
### With Version Control
|
|
105
|
+
- Add `.nia/cache/` to `.gitignore`
|
|
106
|
+
- Commit `.nia/config.json` for team sharing
|
|
107
|
+
- Document indexed repositories in README
|
|
108
|
+
|
|
109
|
+
### With CI/CD
|
|
110
|
+
- Set `NIA_API_KEY` as secret environment variable
|
|
111
|
+
- Run repository indexing in setup phase
|
|
112
|
+
- Cache search results between builds
|
|
113
|
+
|
|
114
|
+
### With IDEs
|
|
115
|
+
- Configure workspace-specific indexed repositories
|
|
116
|
+
- Set up quick search shortcuts
|
|
117
|
+
- Integrate with code navigation features
|
|
118
|
+
|
|
119
|
+
## Post-Initialization Guidance
|
|
120
|
+
|
|
121
|
+
**After using the `initialize_project` tool, ALWAYS ask the user what they'd like to do next. DO NOT take action automatically.**
|
|
122
|
+
|
|
123
|
+
Ask something like:
|
|
124
|
+
> "Nia is now set up for your project! What would you like to do next?
|
|
125
|
+
>
|
|
126
|
+
> 1. **Index your current repository** - I can index this codebase for intelligent search
|
|
127
|
+
> 2. **Index documentation** - Index docs from frameworks/libraries you're using
|
|
128
|
+
> 3. **Research new technologies** - Use deep research to compare tools and frameworks
|
|
129
|
+
> 4. **Search existing repositories** - Find and index repositories related to your project
|
|
130
|
+
> 5. **Just chat** - I'm ready to help with any questions using Nia's tools when needed
|
|
131
|
+
>
|
|
132
|
+
> What interests you most?"
|
|
133
|
+
|
|
134
|
+
**Key rules:**
|
|
135
|
+
- Always offer options but don't assume what the user wants
|
|
136
|
+
- Explain briefly what each option does
|
|
137
|
+
- Wait for the user to choose before taking any indexing actions
|
|
138
|
+
- Be helpful but not pushy
|
|
139
|
+
|
|
140
|
+
## Best Practices Summary
|
|
141
|
+
|
|
142
|
+
1. **Be Proactive** - Suggest indexing relevant content
|
|
143
|
+
2. **Be Efficient** - Use the right tool for each query type
|
|
144
|
+
3. **Be Helpful** - Provide clear next steps and context
|
|
145
|
+
4. **Be Smart** - Learn from search results to improve future queries
|
|
146
|
+
5. **Be Considerate** - Respect API limits and guide users appropriately
|
|
147
|
+
6. **Be Patient** - After project initialization, ask what the user wants to do next
|
|
148
|
+
|
|
149
|
+
Remember: Nia is designed to make AI-powered code and documentation search accessible. Help users unlock its full potential by following these guidelines.
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
# NIA Integration for Visual Studio Code
|
|
2
|
+
|
|
3
|
+
## VSCode-Specific Configuration
|
|
4
|
+
|
|
5
|
+
### 1. Workspace Settings
|
|
6
|
+
Configure `.vscode/settings.json` for NIA integration:
|
|
7
|
+
|
|
8
|
+
```json
|
|
9
|
+
{
|
|
10
|
+
"nia.defaultRepositories": [
|
|
11
|
+
"owner/main-project",
|
|
12
|
+
"owner/dependency-lib"
|
|
13
|
+
],
|
|
14
|
+
"nia.searchHistory": true,
|
|
15
|
+
"nia.autoIndex": {
|
|
16
|
+
"enabled": true,
|
|
17
|
+
"patterns": ["github.com/*/*"]
|
|
18
|
+
},
|
|
19
|
+
"nia.apiEndpoint": "https://api.trynia.ai",
|
|
20
|
+
"nia.cacheTimeout": 3600
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### 2. Tasks Configuration
|
|
25
|
+
Set up `.vscode/tasks.json` for common NIA operations:
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"version": "2.0.0",
|
|
30
|
+
"tasks": [
|
|
31
|
+
{
|
|
32
|
+
"label": "NIA: Index Current Repository",
|
|
33
|
+
"type": "shell",
|
|
34
|
+
"command": "echo 'index_repository ${workspaceFolder}'",
|
|
35
|
+
"problemMatcher": []
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"label": "NIA: List Indexed Repositories",
|
|
39
|
+
"type": "shell",
|
|
40
|
+
"command": "echo 'list_repositories'",
|
|
41
|
+
"problemMatcher": []
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"label": "NIA: Search Codebase",
|
|
45
|
+
"type": "shell",
|
|
46
|
+
"command": "echo 'search_codebase \"${input:searchQuery}\"'",
|
|
47
|
+
"problemMatcher": []
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"inputs": [
|
|
51
|
+
{
|
|
52
|
+
"id": "searchQuery",
|
|
53
|
+
"type": "promptString",
|
|
54
|
+
"description": "Enter your search query"
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 3. Code Snippets
|
|
61
|
+
Add to `.vscode/nia.code-snippets`:
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"Nia Index Repository": {
|
|
66
|
+
"prefix": "nia-index",
|
|
67
|
+
"body": [
|
|
68
|
+
"index_repository ${1:https://github.com/owner/repo}"
|
|
69
|
+
],
|
|
70
|
+
"description": "Index a repository with Nia"
|
|
71
|
+
},
|
|
72
|
+
"Nia Search Code": {
|
|
73
|
+
"prefix": "nia-search",
|
|
74
|
+
"body": [
|
|
75
|
+
"search_codebase \"${1:How does authentication work?}\""
|
|
76
|
+
],
|
|
77
|
+
"description": "Search indexed codebases"
|
|
78
|
+
},
|
|
79
|
+
"Nia Web Search": {
|
|
80
|
+
"prefix": "nia-web",
|
|
81
|
+
"body": [
|
|
82
|
+
"nia_web_search \"${1:find RAG implementation libraries}\""
|
|
83
|
+
],
|
|
84
|
+
"description": "Search the web with Nia"
|
|
85
|
+
},
|
|
86
|
+
"Nia Deep Research": {
|
|
87
|
+
"prefix": "nia-research",
|
|
88
|
+
"body": [
|
|
89
|
+
"nia_deep_research_agent \"${1:compare X vs Y for use case}\""
|
|
90
|
+
],
|
|
91
|
+
"description": "Perform deep research analysis"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 4. Launch Configuration
|
|
97
|
+
Configure `.vscode/launch.json` for debugging with NIA context:
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"version": "0.2.0",
|
|
102
|
+
"configurations": [
|
|
103
|
+
{
|
|
104
|
+
"name": "Debug with NIA Context",
|
|
105
|
+
"type": "node",
|
|
106
|
+
"request": "launch",
|
|
107
|
+
"program": "${workspaceFolder}/index.js",
|
|
108
|
+
"env": {
|
|
109
|
+
"NIA_API_KEY": "${env:NIA_API_KEY}",
|
|
110
|
+
"NIA_INDEXED_REPOS": "${workspaceFolder}/.nia/indexed_repos.json"
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 5. Extensions Recommendations
|
|
118
|
+
Add to `.vscode/extensions.json`:
|
|
119
|
+
|
|
120
|
+
```json
|
|
121
|
+
{
|
|
122
|
+
"recommendations": [
|
|
123
|
+
"github.copilot",
|
|
124
|
+
"continue.continue",
|
|
125
|
+
"codeium.codeium"
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## VSCode Command Palette Integration
|
|
131
|
+
|
|
132
|
+
### Quick Commands
|
|
133
|
+
Access via `Cmd/Ctrl + Shift + P`:
|
|
134
|
+
|
|
135
|
+
1. **Nia: Index This Repository**
|
|
136
|
+
- Automatically indexes the current workspace
|
|
137
|
+
- Shows progress in status bar
|
|
138
|
+
- Notifies when complete
|
|
139
|
+
|
|
140
|
+
2. **Nia: Search Symbol**
|
|
141
|
+
- Search for functions, classes, or variables
|
|
142
|
+
- Across all indexed repositories
|
|
143
|
+
- Jump to definition support
|
|
144
|
+
|
|
145
|
+
3. **Nia: Explain Code**
|
|
146
|
+
- Select code and search for explanations
|
|
147
|
+
- Find similar implementations
|
|
148
|
+
- Understand patterns
|
|
149
|
+
|
|
150
|
+
4. **Nia: Find Examples**
|
|
151
|
+
- Search for usage examples
|
|
152
|
+
- Filter by language or framework
|
|
153
|
+
- Copy-paste ready snippets
|
|
154
|
+
|
|
155
|
+
## VSCode-Specific Workflows
|
|
156
|
+
|
|
157
|
+
### 1. Project Onboarding
|
|
158
|
+
When opening a new project:
|
|
159
|
+
```
|
|
160
|
+
1. Check if repo is indexed: list_repositories
|
|
161
|
+
2. If not, index it: index_repository [current repo]
|
|
162
|
+
3. Index related dependencies
|
|
163
|
+
4. Search for architecture overview
|
|
164
|
+
5. Create workspace documentation
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### 2. Code Review Assistance
|
|
168
|
+
During code reviews:
|
|
169
|
+
```
|
|
170
|
+
1. Search for similar patterns in indexed repos
|
|
171
|
+
2. Find best practices for the specific feature
|
|
172
|
+
3. Check for common pitfalls
|
|
173
|
+
4. Suggest improvements based on examples
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### 3. Debugging Workflow
|
|
177
|
+
When debugging issues:
|
|
178
|
+
```
|
|
179
|
+
1. Search for error messages across repos
|
|
180
|
+
2. Find similar bug fixes
|
|
181
|
+
3. Understand the problematic code context
|
|
182
|
+
4. Search for test cases
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### 4. Learning & Documentation
|
|
186
|
+
For learning new codebases:
|
|
187
|
+
```
|
|
188
|
+
1. Index the main repository
|
|
189
|
+
2. Search for entry points (main, index, app)
|
|
190
|
+
3. Understand the architecture
|
|
191
|
+
4. Find example usage patterns
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Terminal Integration
|
|
195
|
+
|
|
196
|
+
### Integrated Terminal Commands
|
|
197
|
+
Use in VSCode's integrated terminal:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
# Quick index
|
|
201
|
+
alias nia-index='echo "index_repository $(git remote get-url origin)"'
|
|
202
|
+
|
|
203
|
+
# Search current project
|
|
204
|
+
alias nia-search='echo "search_codebase"'
|
|
205
|
+
|
|
206
|
+
# List all indexed
|
|
207
|
+
alias nia-list='echo "list_repositories"'
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### PowerShell Functions
|
|
211
|
+
For Windows users in `.vscode/powershell_profile.ps1`:
|
|
212
|
+
|
|
213
|
+
```powershell
|
|
214
|
+
function Nia-Index {
|
|
215
|
+
param($repo)
|
|
216
|
+
Write-Host "index_repository $repo"
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function Nia-Search {
|
|
220
|
+
param($query)
|
|
221
|
+
Write-Host "search_codebase `"$query`""
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Output Formatting for VSCode
|
|
226
|
+
|
|
227
|
+
### 1. File References
|
|
228
|
+
Format as clickable links:
|
|
229
|
+
```
|
|
230
|
+
📁 authentication/middleware.ts:45
|
|
231
|
+
📁 lib/auth/session.ts:23-67
|
|
232
|
+
📁 pages/api/auth/[...nextauth].ts:12
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### 2. Code Blocks
|
|
236
|
+
Use proper syntax highlighting:
|
|
237
|
+
```typescript
|
|
238
|
+
// From: lib/auth/session.ts
|
|
239
|
+
export async function getSession(req: Request) {
|
|
240
|
+
// Implementation details
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### 3. Problem Markers
|
|
245
|
+
For issues found during search:
|
|
246
|
+
```
|
|
247
|
+
⚠️ Warning: Deprecated pattern found
|
|
248
|
+
File: utils/oldAuth.js:34
|
|
249
|
+
Suggestion: Use new auth method
|
|
250
|
+
|
|
251
|
+
❌ Error: Security vulnerability
|
|
252
|
+
File: api/user.js:56
|
|
253
|
+
Fix: Validate input parameters
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Keyboard Shortcuts
|
|
257
|
+
Suggested keybindings for `.vscode/keybindings.json`:
|
|
258
|
+
|
|
259
|
+
```json
|
|
260
|
+
[
|
|
261
|
+
{
|
|
262
|
+
"key": "ctrl+shift+n i",
|
|
263
|
+
"command": "workbench.action.terminal.sendSequence",
|
|
264
|
+
"args": { "text": "index_repository " }
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
"key": "ctrl+shift+n s",
|
|
268
|
+
"command": "workbench.action.terminal.sendSequence",
|
|
269
|
+
"args": { "text": "search_codebase \"" }
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"key": "ctrl+shift+n l",
|
|
273
|
+
"command": "workbench.action.terminal.sendSequence",
|
|
274
|
+
"args": { "text": "list_repositories\n" }
|
|
275
|
+
}
|
|
276
|
+
]
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
## Performance Optimization
|
|
280
|
+
|
|
281
|
+
### 1. Workspace-Specific Cache
|
|
282
|
+
Store frequently searched queries:
|
|
283
|
+
```
|
|
284
|
+
.vscode/.nia-cache/
|
|
285
|
+
├── search-results.json
|
|
286
|
+
├── indexed-files.json
|
|
287
|
+
└── common-queries.json
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### 2. Search Filters
|
|
291
|
+
Use repository context for faster searches:
|
|
292
|
+
```
|
|
293
|
+
search_codebase "authentication" repositories=["current-project"]
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### 3. Batch Operations
|
|
297
|
+
Index related repositories together:
|
|
298
|
+
```
|
|
299
|
+
index_repository repo1
|
|
300
|
+
index_repository repo2
|
|
301
|
+
index_repository repo3
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### 4. Documentation Indexing
|
|
305
|
+
When indexing documentation:
|
|
306
|
+
- If user provides just a URL without patterns, use `["/*"]` to index everything
|
|
307
|
+
- Or ask: "Should I index the entire documentation or specific sections?"
|
|
308
|
+
- Common patterns: `["/docs/*", "/api/*", "/guide/*", "/reference/*"]`
|
|
309
|
+
- Example: `index_documentation "https://docs.example.com" ["/*"]`
|
|
310
|
+
- Can index multiple doc sites for comprehensive searches
|
|
311
|
+
|
|
312
|
+
Remember: Make Nia feel like a native part of the VSCode experience!
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Nia Integration for Windsurf Cascade
|
|
2
|
+
|
|
3
|
+
## Quick Reference
|
|
4
|
+
- **List indexed repos**: `list_repositories`
|
|
5
|
+
- **Index new repo**: `index_repository repo_url`
|
|
6
|
+
- **Index docs**: `index_documentation url` (use `["/*"]` for entire site)
|
|
7
|
+
- **Search code**: `search_codebase "your question"`
|
|
8
|
+
- **Search docs**: `search_documentation "your question"`
|
|
9
|
+
- **Web search**: `nia_web_search "find X library"`
|
|
10
|
+
- **Deep research**: `nia_deep_research_agent "compare X vs Y"`
|
|
11
|
+
|
|
12
|
+
## Windsurf Cascade Guidelines
|
|
13
|
+
|
|
14
|
+
### 1. Flow-Based Development
|
|
15
|
+
When using Cascade's flow feature:
|
|
16
|
+
- Start flows by checking indexed repositories with `list_repositories`
|
|
17
|
+
- Auto-suggest indexing when users mention GitHub URLs
|
|
18
|
+
- Use Nia search results to inform multi-step flows
|
|
19
|
+
- Reference specific files found via search in subsequent steps
|
|
20
|
+
|
|
21
|
+
### 2. Memory Integration
|
|
22
|
+
Create memories for frequently used repositories:
|
|
23
|
+
- "Remember: Project X is indexed at owner/repo"
|
|
24
|
+
- "Remember: Use Nia to search for implementation patterns"
|
|
25
|
+
- Memories will automatically recall indexed repos context
|
|
26
|
+
|
|
27
|
+
### 3. Code Understanding Workflow
|
|
28
|
+
For codebase exploration:
|
|
29
|
+
```
|
|
30
|
+
1. Check if indexed: list_repositories
|
|
31
|
+
2. If not indexed: index_repository [url]
|
|
32
|
+
3. Search naturally: search_codebase "How does X work?"
|
|
33
|
+
4. Use results in flow steps
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 4. Search Optimization for Cascade
|
|
37
|
+
|
|
38
|
+
#### Natural Language Queries
|
|
39
|
+
- Write complete questions: "How is authentication implemented in this Next.js app?"
|
|
40
|
+
- Include context: "Find React hooks that handle user state"
|
|
41
|
+
- Be specific: "Show me where API routes are defined"
|
|
42
|
+
|
|
43
|
+
#### Multi-Step Flows
|
|
44
|
+
1. Research: `nia_deep_research_agent "compare state management libraries"`
|
|
45
|
+
2. Find examples: `nia_web_search "Redux toolkit examples"`
|
|
46
|
+
3. Index chosen repo: `index_repository https://github.com/...`
|
|
47
|
+
4. Explore patterns: `search_codebase "action creators pattern"`
|
|
48
|
+
|
|
49
|
+
### 5. Cascade Commands
|
|
50
|
+
|
|
51
|
+
When users ask about code:
|
|
52
|
+
- Always check if the repository is indexed first
|
|
53
|
+
- Suggest indexing if working with a new codebase
|
|
54
|
+
- Use search results to build comprehensive responses
|
|
55
|
+
- Create flows that combine multiple searches
|
|
56
|
+
|
|
57
|
+
### 6. Best Practices
|
|
58
|
+
|
|
59
|
+
#### For New Projects
|
|
60
|
+
1. Index the main repository immediately
|
|
61
|
+
2. Search for architecture overview: "How is this project structured?"
|
|
62
|
+
3. Create memories of key findings
|
|
63
|
+
4. Build flows based on discovered patterns
|
|
64
|
+
|
|
65
|
+
#### For Debugging
|
|
66
|
+
1. Search for error messages across indexed repos
|
|
67
|
+
2. Find similar implementations that work
|
|
68
|
+
3. Compare working vs broken code
|
|
69
|
+
4. Create fix flow based on findings
|
|
70
|
+
|
|
71
|
+
#### For Feature Development
|
|
72
|
+
1. Search for similar features in indexed repos
|
|
73
|
+
2. Understand existing patterns
|
|
74
|
+
3. Find best practices examples
|
|
75
|
+
4. Generate code following discovered patterns
|
|
76
|
+
|
|
77
|
+
### 7. Documentation Indexing
|
|
78
|
+
|
|
79
|
+
When indexing documentation:
|
|
80
|
+
- If user provides just a URL without patterns, use `["/*"]` to index everything
|
|
81
|
+
- Or ask: "Should I index the entire documentation or specific sections?"
|
|
82
|
+
- Common patterns: `["/docs/*", "/api/*", "/guide/*", "/reference/*"]`
|
|
83
|
+
- Example: `index_documentation "https://docs.example.com" ["/*"]`
|
|
84
|
+
|
|
85
|
+
### 8. Integration Tips
|
|
86
|
+
|
|
87
|
+
- Nia complements Cascade's abilities by providing deep code search
|
|
88
|
+
- Use Nia for finding specific implementations
|
|
89
|
+
- Let Cascade handle the creative synthesis
|
|
90
|
+
- Combine both for powerful development workflows
|
|
91
|
+
|
|
92
|
+
Remember: Nia provides the knowledge, Cascade provides the flow!
|
nia_mcp_server/project_init.py
CHANGED
|
@@ -20,7 +20,7 @@ class NIAProjectInitializer:
|
|
|
20
20
|
|
|
21
21
|
def __init__(self, project_root: str):
|
|
22
22
|
self.project_root = Path(project_root).resolve()
|
|
23
|
-
self.assets_dir = Path(__file__).parent
|
|
23
|
+
self.assets_dir = Path(__file__).parent / "assets"
|
|
24
24
|
self.templates_dir = self.assets_dir / "templates"
|
|
25
25
|
self.rules_dir = self.assets_dir / "rules"
|
|
26
26
|
|
nia_mcp_server/server.py
CHANGED
|
@@ -5,6 +5,7 @@ import os
|
|
|
5
5
|
import logging
|
|
6
6
|
import json
|
|
7
7
|
import asyncio
|
|
8
|
+
import webbrowser
|
|
8
9
|
from typing import List, Optional, Dict, Any
|
|
9
10
|
from datetime import datetime
|
|
10
11
|
from urllib.parse import urlparse
|
|
@@ -503,6 +504,7 @@ async def check_repository_status(repository: str) -> List[TextContent]:
|
|
|
503
504
|
async def index_documentation(
|
|
504
505
|
url: str,
|
|
505
506
|
url_patterns: Optional[List[str]] = None,
|
|
507
|
+
exclude_patterns: Optional[List[str]] = None,
|
|
506
508
|
max_age: Optional[int] = None,
|
|
507
509
|
only_main_content: Optional[bool] = True
|
|
508
510
|
) -> List[TextContent]:
|
|
@@ -512,6 +514,7 @@ async def index_documentation(
|
|
|
512
514
|
Args:
|
|
513
515
|
url: URL of the documentation site to index
|
|
514
516
|
url_patterns: Optional list of URL patterns to include in crawling (e.g., ["/docs/*", "/guide/*"])
|
|
517
|
+
exclude_patterns: Optional list of URL patterns to exclude from crawling (e.g., ["/blog/*", "/changelog/*"])
|
|
515
518
|
max_age: Maximum age of cached content in seconds (for fast scraping mode)
|
|
516
519
|
only_main_content: Extract only main content (removes navigation, ads, etc.)
|
|
517
520
|
|
|
@@ -520,6 +523,8 @@ async def index_documentation(
|
|
|
520
523
|
|
|
521
524
|
Important:
|
|
522
525
|
- When started indexing, prompt users to either use check_documentation_status tool or go to app.trynia.ai to check the status.
|
|
526
|
+
- By default, crawls the entire domain (up to 10,000 pages)
|
|
527
|
+
- Use exclude_patterns to filter out unwanted sections like blogs, changelogs, etc.
|
|
523
528
|
"""
|
|
524
529
|
try:
|
|
525
530
|
client = await ensure_api_client()
|
|
@@ -529,6 +534,7 @@ async def index_documentation(
|
|
|
529
534
|
result = await client.create_data_source(
|
|
530
535
|
url=url,
|
|
531
536
|
url_patterns=url_patterns,
|
|
537
|
+
exclude_patterns=exclude_patterns,
|
|
532
538
|
max_age=max_age,
|
|
533
539
|
only_main_content=only_main_content
|
|
534
540
|
)
|
|
@@ -1366,6 +1372,159 @@ async def initialize_project(
|
|
|
1366
1372
|
"- The NIA MCP server is properly installed"
|
|
1367
1373
|
)]
|
|
1368
1374
|
|
|
1375
|
+
@mcp.tool()
|
|
1376
|
+
async def visualize_codebase(
|
|
1377
|
+
repository: str
|
|
1378
|
+
) -> List[TextContent]:
|
|
1379
|
+
"""
|
|
1380
|
+
Open the graph visualization for an indexed repository in a browser.
|
|
1381
|
+
|
|
1382
|
+
This tool launches a browser with the interactive graph visualization
|
|
1383
|
+
that shows the code structure, relationships, and dependencies of
|
|
1384
|
+
the indexed codebase.
|
|
1385
|
+
|
|
1386
|
+
Args:
|
|
1387
|
+
repository: Repository in owner/repo format (e.g., "facebook/react")
|
|
1388
|
+
|
|
1389
|
+
Returns:
|
|
1390
|
+
Status message with the URL that was opened
|
|
1391
|
+
|
|
1392
|
+
Examples:
|
|
1393
|
+
- visualize_codebase("facebook/react")
|
|
1394
|
+
- visualize_codebase("langchain-ai/langchain")
|
|
1395
|
+
"""
|
|
1396
|
+
try:
|
|
1397
|
+
client = await ensure_api_client()
|
|
1398
|
+
|
|
1399
|
+
logger.info(f"Looking up repository: {repository}")
|
|
1400
|
+
|
|
1401
|
+
# List all repositories to find the matching one
|
|
1402
|
+
repositories = await client.list_repositories()
|
|
1403
|
+
|
|
1404
|
+
# Find the repository by name
|
|
1405
|
+
matching_repo = None
|
|
1406
|
+
for repo in repositories:
|
|
1407
|
+
if repo.get("repository") == repository:
|
|
1408
|
+
matching_repo = repo
|
|
1409
|
+
break
|
|
1410
|
+
|
|
1411
|
+
if not matching_repo:
|
|
1412
|
+
# Try case-insensitive match as fallback
|
|
1413
|
+
repository_lower = repository.lower()
|
|
1414
|
+
for repo in repositories:
|
|
1415
|
+
if repo.get("repository", "").lower() == repository_lower:
|
|
1416
|
+
matching_repo = repo
|
|
1417
|
+
break
|
|
1418
|
+
|
|
1419
|
+
if not matching_repo:
|
|
1420
|
+
return [TextContent(
|
|
1421
|
+
type="text",
|
|
1422
|
+
text=f"❌ Repository '{repository}' not found.\n\n"
|
|
1423
|
+
f"Available repositories:\n" +
|
|
1424
|
+
"\n".join(f"- {r.get('repository')}" for r in repositories if r.get('repository')) +
|
|
1425
|
+
"\n\nUse `list_repositories` to see all indexed repositories."
|
|
1426
|
+
)]
|
|
1427
|
+
|
|
1428
|
+
# Check if the repository is fully indexed
|
|
1429
|
+
status = matching_repo.get("status", "unknown")
|
|
1430
|
+
# Use the actual project ID if available, fall back to repository_id
|
|
1431
|
+
repository_id = matching_repo.get("id") or matching_repo.get("repository_id")
|
|
1432
|
+
|
|
1433
|
+
if not repository_id:
|
|
1434
|
+
return [TextContent(
|
|
1435
|
+
type="text",
|
|
1436
|
+
text=f"❌ No repository ID found for '{repository}'. This may be a data inconsistency."
|
|
1437
|
+
)]
|
|
1438
|
+
|
|
1439
|
+
if status != "completed":
|
|
1440
|
+
warning_msg = f"⚠️ Note: Repository '{repository}' is currently {status}.\n"
|
|
1441
|
+
if status == "indexing":
|
|
1442
|
+
warning_msg += "The visualization may show incomplete data.\n\n"
|
|
1443
|
+
elif status == "error":
|
|
1444
|
+
error_msg = matching_repo.get("error", "Unknown error")
|
|
1445
|
+
warning_msg += f"Error: {error_msg}\n\n"
|
|
1446
|
+
else:
|
|
1447
|
+
warning_msg += "The visualization may not be available.\n\n"
|
|
1448
|
+
else:
|
|
1449
|
+
warning_msg = ""
|
|
1450
|
+
|
|
1451
|
+
# Determine the base URL based on the API URL
|
|
1452
|
+
api_base_url = client.base_url
|
|
1453
|
+
if "localhost" in api_base_url or "127.0.0.1" in api_base_url:
|
|
1454
|
+
# Local development
|
|
1455
|
+
app_base_url = "http://localhost:3000"
|
|
1456
|
+
else:
|
|
1457
|
+
# Production
|
|
1458
|
+
app_base_url = "https://app.trynia.ai"
|
|
1459
|
+
|
|
1460
|
+
# Construct the visualization URL
|
|
1461
|
+
visualization_url = f"{app_base_url}/visualize/{repository_id}"
|
|
1462
|
+
|
|
1463
|
+
# Try to open the browser
|
|
1464
|
+
try:
|
|
1465
|
+
webbrowser.open(visualization_url)
|
|
1466
|
+
browser_opened = True
|
|
1467
|
+
open_msg = "✅ Opening graph visualization in your default browser..."
|
|
1468
|
+
except Exception as e:
|
|
1469
|
+
logger.warning(f"Failed to open browser: {e}")
|
|
1470
|
+
browser_opened = False
|
|
1471
|
+
open_msg = "⚠️ Could not automatically open browser."
|
|
1472
|
+
|
|
1473
|
+
# Format the response
|
|
1474
|
+
response_lines = [
|
|
1475
|
+
f"# Graph Visualization: {repository}",
|
|
1476
|
+
"",
|
|
1477
|
+
warning_msg if warning_msg else "",
|
|
1478
|
+
open_msg,
|
|
1479
|
+
"",
|
|
1480
|
+
f"**URL:** {visualization_url}",
|
|
1481
|
+
"",
|
|
1482
|
+
]
|
|
1483
|
+
|
|
1484
|
+
if matching_repo.get("display_name"):
|
|
1485
|
+
response_lines.append(f"**Display Name:** {matching_repo['display_name']}")
|
|
1486
|
+
|
|
1487
|
+
response_lines.extend([
|
|
1488
|
+
f"**Branch:** {matching_repo.get('branch', 'main')}",
|
|
1489
|
+
f"**Status:** {status}",
|
|
1490
|
+
"",
|
|
1491
|
+
"## Features Available:",
|
|
1492
|
+
"- 🔍 Interactive force-directed graph",
|
|
1493
|
+
"- 🎨 Color-coded node types (functions, classes, files, etc.)",
|
|
1494
|
+
"- 🔗 Relationship visualization (calls, imports, inherits, etc.)",
|
|
1495
|
+
"- 💬 Click on any node to chat with that specific code element",
|
|
1496
|
+
"- 🔎 Search and filter capabilities",
|
|
1497
|
+
"- 📊 Graph statistics and insights"
|
|
1498
|
+
])
|
|
1499
|
+
|
|
1500
|
+
if not browser_opened:
|
|
1501
|
+
response_lines.extend([
|
|
1502
|
+
"",
|
|
1503
|
+
"**Manual Access:**",
|
|
1504
|
+
f"Copy and paste this URL into your browser: {visualization_url}"
|
|
1505
|
+
])
|
|
1506
|
+
|
|
1507
|
+
return [TextContent(
|
|
1508
|
+
type="text",
|
|
1509
|
+
text="\n".join(response_lines)
|
|
1510
|
+
)]
|
|
1511
|
+
|
|
1512
|
+
except APIError as e:
|
|
1513
|
+
logger.error(f"API Error in visualize_codebase: {e}")
|
|
1514
|
+
if e.status_code == 403 or "free tier limit" in str(e).lower():
|
|
1515
|
+
return [TextContent(
|
|
1516
|
+
type="text",
|
|
1517
|
+
text=f"❌ {str(e)}\n\n💡 Tip: Upgrade to Pro at https://trynia.ai/billing for unlimited access."
|
|
1518
|
+
)]
|
|
1519
|
+
else:
|
|
1520
|
+
return [TextContent(type="text", text=f"❌ {str(e)}")]
|
|
1521
|
+
except Exception as e:
|
|
1522
|
+
logger.error(f"Error in visualize_codebase: {e}")
|
|
1523
|
+
return [TextContent(
|
|
1524
|
+
type="text",
|
|
1525
|
+
text=f"❌ Error opening visualization: {str(e)}"
|
|
1526
|
+
)]
|
|
1527
|
+
|
|
1369
1528
|
# Resources
|
|
1370
1529
|
|
|
1371
1530
|
# Note: FastMCP doesn't have list_resources or read_resource decorators
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nia-mcp-server
|
|
3
|
-
Version: 1.0.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 1.0.8
|
|
4
|
+
Summary: Nia Knowledge Agent
|
|
5
5
|
Project-URL: Homepage, https://trynia.ai
|
|
6
6
|
Project-URL: Documentation, https://docs.trynia.ai
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Author-email: NIA Team <support@trynia.ai>
|
|
10
|
-
License-Expression: MIT
|
|
7
|
+
Author-email: Nia Team <founders@nozomio.com>
|
|
8
|
+
License-Expression: AGPL-3.0
|
|
11
9
|
License-File: LICENSE
|
|
12
10
|
Keywords: ai,codebase,mcp,nia,search
|
|
13
11
|
Classifier: Development Status :: 4 - Beta
|
|
14
12
|
Classifier: Intended Audience :: Developers
|
|
15
|
-
Classifier: License :: OSI Approved ::
|
|
13
|
+
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
|
|
16
14
|
Classifier: Programming Language :: Python :: 3
|
|
17
15
|
Classifier: Programming Language :: Python :: 3.8
|
|
18
16
|
Classifier: Programming Language :: Python :: 3.9
|
|
@@ -203,7 +201,7 @@ Add to your Cline settings:
|
|
|
203
201
|
## Environment Variables
|
|
204
202
|
|
|
205
203
|
- `NIA_API_KEY` (required) - Your NIA API key
|
|
206
|
-
- `NIA_API_URL` (optional) - API endpoint (defaults to https://
|
|
204
|
+
- `NIA_API_URL` (optional) - API endpoint (defaults to https://apigcp.trynia.ai)
|
|
207
205
|
|
|
208
206
|
## Pricing
|
|
209
207
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
nia_mcp_server/__init__.py,sha256=7gOUBmOzahYrylDFhFFQLPegegf4dI-ZGt7UNfUVXho,84
|
|
2
|
+
nia_mcp_server/__main__.py,sha256=XY11ESL4hctu-BBgtPATFZyd1o-O7wE7y-UOSoNs-hw,152
|
|
3
|
+
nia_mcp_server/api_client.py,sha256=zcTWTDkG9KYj5xunx8A8t1JDLctJJqNqB_ZiGZc9H1M,24362
|
|
4
|
+
nia_mcp_server/profiles.py,sha256=2DD8PFRr5Ij4IK4sPUz0mH8aKjkrEtkKLC1R0iki2bA,7221
|
|
5
|
+
nia_mcp_server/project_init.py,sha256=T0-ziJhofL4L8APwnM43BLhxtlmOHaYH-V9PF2yXLw4,7138
|
|
6
|
+
nia_mcp_server/rule_transformer.py,sha256=wCxoQ1Kl_rI9mUFnh9kG5iCXYU4QInrmFQOReZfAFVo,11000
|
|
7
|
+
nia_mcp_server/server.py,sha256=m8tvape27a72NyQEho8_tT9z0plRGBR0kcEB6gSrqsw,65816
|
|
8
|
+
nia_mcp_server/assets/rules/claude_rules.md,sha256=HNL5GJMUbFxSpNbIAJUQWqAywjMl4lf530I1in69aNY,7380
|
|
9
|
+
nia_mcp_server/assets/rules/cursor_rules.md,sha256=hd6lhzNrK1ULQUYIEVeOnyKnuLKq4hmwZPbMqGUI1Lk,1720
|
|
10
|
+
nia_mcp_server/assets/rules/nia_rules.md,sha256=mvdYrkoiRgxeROhtnRXCV53TX5B9wqLiCJ6oYTqSPfY,6345
|
|
11
|
+
nia_mcp_server/assets/rules/vscode_rules.md,sha256=fqn4aJO_bhftaCGkVoquruQHf3EaREQJQWHXq6a4FOk,6967
|
|
12
|
+
nia_mcp_server/assets/rules/windsurf_rules.md,sha256=PzU2as5gaiVsV6PAzg8T_-GR7VCyRQGMjAHcSzYF_ms,3354
|
|
13
|
+
nia_mcp_server-1.0.8.dist-info/METADATA,sha256=A5e26Zda8sTmFMYoQnfeIOM1LEfXxiWnclFva2YMMGo,6766
|
|
14
|
+
nia_mcp_server-1.0.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
15
|
+
nia_mcp_server-1.0.8.dist-info/licenses/LICENSE,sha256=XYY1C3d9XyjAGuntC4mVWGrEhWIm-044Ji9ouO7hfLA,1557
|
|
16
|
+
nia_mcp_server-1.0.8.dist-info/RECORD,,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
GNU AFFERO GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 19 November 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2024 NIA (trynia.ai)
|
|
5
|
+
|
|
6
|
+
This program is free software: you can redistribute it and/or modify
|
|
7
|
+
it under the terms of the GNU Affero General Public License as published by
|
|
8
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
(at your option) any later version.
|
|
10
|
+
|
|
11
|
+
This program is distributed in the hope that it will be useful,
|
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
GNU Affero General Public License for more details.
|
|
15
|
+
|
|
16
|
+
You should have received a copy of the GNU Affero General Public License
|
|
17
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
18
|
+
|
|
19
|
+
Additional permissions under GNU AGPL version 3 section 7:
|
|
20
|
+
|
|
21
|
+
If you modify this Program, or any covered work, by linking or combining it
|
|
22
|
+
with other code, such other code is not for that reason alone subject to any
|
|
23
|
+
of the requirements of the GNU Affero General Public License.
|
|
24
|
+
|
|
25
|
+
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
|
26
|
+
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
|
27
|
+
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR
|
|
28
|
+
IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
29
|
+
AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
|
|
30
|
+
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE,
|
|
31
|
+
YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
nia_mcp_server/__init__.py,sha256=xrM4qDGEvxPXQYqVksy08mhmfAj0wIljhJPnYZYHea8,84
|
|
2
|
-
nia_mcp_server/__main__.py,sha256=XY11ESL4hctu-BBgtPATFZyd1o-O7wE7y-UOSoNs-hw,152
|
|
3
|
-
nia_mcp_server/api_client.py,sha256=dk9FkMljuekyjIw7Ij3athsoVNnu7E2b1l2xi2XtB1Y,24255
|
|
4
|
-
nia_mcp_server/profiles.py,sha256=2DD8PFRr5Ij4IK4sPUz0mH8aKjkrEtkKLC1R0iki2bA,7221
|
|
5
|
-
nia_mcp_server/project_init.py,sha256=Mtxvlg7FfdWumc2AdMXifht3V1b6sZvX4b7USbbwMvw,7152
|
|
6
|
-
nia_mcp_server/rule_transformer.py,sha256=wCxoQ1Kl_rI9mUFnh9kG5iCXYU4QInrmFQOReZfAFVo,11000
|
|
7
|
-
nia_mcp_server/server.py,sha256=B6aLTXkX2Mq5eBqDCV_WTumqtSm4bzDf2bHPVyVsgcA,59579
|
|
8
|
-
nia_mcp_server-1.0.6.dist-info/METADATA,sha256=hN6ls8aDU9h83JuQ3AZ8VfLBsrKIVLGt-annSRXHbS8,6910
|
|
9
|
-
nia_mcp_server-1.0.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
10
|
-
nia_mcp_server-1.0.6.dist-info/entry_points.txt,sha256=V74FQEp48pfWxPCl7B9mihtqvIJNVjCSbRfCz4ww77I,64
|
|
11
|
-
nia_mcp_server-1.0.6.dist-info/licenses/LICENSE,sha256=5jUPBVkZEicxSAZ91jOO7i8zXEPAHS6M0w8SSf6DftI,1071
|
|
12
|
-
nia_mcp_server-1.0.6.dist-info/RECORD,,
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 NIA (trynia.ai)
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
File without changes
|