Add Kubernetes and Jira MCP tools with auto-registration

This commit is contained in:
2026-04-13 14:15:00 +03:00
parent 87fb9e8df8
commit b5eb33272a
10 changed files with 443 additions and 433 deletions

256
AGENTS.md
View File

@@ -1,245 +1,35 @@
## AGENTS.md
# AGENTS.md
### PRIORITY
## Scope
1. User request
2. This file
3. Existing code
- `LazyBearWorks.sln` builds exactly one project: `LazyBear.MCP/`. `Libraries/Confluence/` is present in the repo but is not part of the solution and has no `.csproj`; ignore it unless the user explicitly asks for it.
---
## Source Of Truth
## CODE
- Trust `LazyBear.MCP/Program.cs` and project config over `README.md`. The README describes Razor Pages/UI and a broader tool surface, but the current app only configures MCP HTTP transport and auto-registers tool classes from the assembly.
### STACK
## Entry Points
* .NET / C#
* ASP.NET Core
* MCP
- Main app entrypoint: `LazyBear.MCP/Program.cs`.
- Live MCP tools are discovered via `AddMcpServer().WithHttpTransport().WithToolsFromAssembly()`. Current tool classes are under `LazyBear.MCP/Services/Kubernetes/` and `LazyBear.MCP/Services/Jira/` and use `[McpServerToolType]`.
- Do not assume Razor Pages are active just because `Pages/` exists: `Program.cs` does not call `AddRazorPages()` or `MapRazorPages()`.
### STRUCTURE
## Commands
* `Server/` — endpoints
* `Services/` — business logic
* `Tools/` — MCP tools
- Build from repo root: `dotnet build`
- Build project directly: `dotnet build "LazyBear.MCP/LazyBear.MCP.csproj"`
- Run from repo root: `dotnet run --project "LazyBear.MCP"`
- MCP manual check: `npx @modelcontextprotocol/inspector dotnet run --project LazyBear.MCP`
- There are no test projects in the solution right now; default verification is `dotnet build`, plus a focused run/inspector check for transport or tool-registration changes.
### RULES
## Runtime Quirks
**Before edit**
- `LazyBear.MCP/Properties/launchSettings.json` says `http://localhost:5079`, but the app actually listens on `http://localhost:5000` because `Program.cs` hardcodes `app.Run("http://localhost:5000")`.
- SDK pin is in `LazyBear.MCP/global.json` (`10.0.100`), not at the repo root.
* Read related code
* Reuse existing patterns
* Do not over-engineer
## Config Gotchas
**After edit**
* Run:
```
dotnet build
```
* Build must succeed
* Do not break MCP protocol
* Keep diff minimal
**Style**
* Match existing style
* Avoid duplication
* Prefer small changes
---
## COMMUNICATION
### LANGUAGE
* Output: Russian
* Code: English
* Comments/commits: Russian
### BEHAVIOR
* Be concise
* Do not explain obvious things
* Do not produce long texts
* Prefer action when no clarification is needed
---
### QUESTIONS
Default:
* If result can be improved by user choice → ASK FIRST
* Do not execute immediately if preferences affect result
Ask BEFORE action if:
* Multiple valid directions exist
* Result depends on user preference
* Request is broad (e.g. "suggest", "recommend", "generate")
Otherwise:
* Proceed with best reasonable assumption
---
### QUESTION TOOL
`question` is the UI tool for user choices in OpenCode.
Use `question` BEFORE answering when:
* 2+ meaningful options exist
* clarification improves result quality
* choice affects architecture, config, data, or output
Do NOT skip `question` in these cases.
Do NOT use when:
* request is already specific
* only one valid answer exists
* clarification does not change result
If unavailable:
* ask in plain text
---
### RESTRICTIONS
* Do not end with only a question
* Do not expose secrets
* Do not repeat user text
---
## TOOLS
Always assume tools MAY be available.
Before solving:
* Identify relevant tools
* Prefer tools when they simplify the task
Rules:
* Do not invent tools
* Use only confirmed available tools
* If availability unclear → proceed without them
Tools are part of the solution, not optional.
---
## MEMORY
Use ONLY if memory tools are available.
### READ FIRST
Before coding or assumptions:
1. Try `read_graph`
2. Then `search_nodes()`
3. Avoid duplicate observations
If unavailable:
* Skip memory usage
### KEY FORMAT
```text
lazybear/<type>/<name>
```
Examples:
```text
lazybear/bug/auth-fail
lazybear/decision/mcp-timeout
lazybear/config/jira-base-url
```
### ALLOWED TYPES
* `architecture`
* `mcp_tool`
* `decision`
* `bug`
* `config`
* `task_log`
### WRITE ONLY WHEN USEFUL
* architecture changes → `architecture`
* new MCP tools → `mcp_tool`
* major decisions → `decision`
* important bugs → `bug`
* config changes → `config`
* completed non-trivial tasks → `task_log`
### RULES
* One entity = one type
* Keep entries short
* Do not duplicate
* Skip trivial changes
---
## SECRETS
* Never print secrets
* Never commit `.env.local`
Use:
* `.env.local` → runtime
* `.env.example` → reference
---
## LINKS
Internal:
* Relative paths
* Spaces → `%20`
External:
* Markdown links only
---
## EDITING RULES
* Do not modify this file unless asked
* Do not change structure
* Keep instructions short and explicit
---
## CORE BEHAVIOR
* Ask first if it improves result quality
* Otherwise act
* Always consider tools before solving
* Prefer tools when useful
* Minimal changes only
* Do not invent tools
* Use tools only if confirmed available
* Never leak secrets
- App config lives in `LazyBear.MCP/appsettings.json`.
- `Kubernetes:KubeconfigPath` defaults empty. `K8sClientFactory` then tries the default kubeconfig, then in-cluster config.
- Jira tools require `Jira:Url`; if it is empty, `JiraClientFactory` throws during provider setup. The app still starts because providers capture init errors and tools return those errors as strings.
- Treat `appsettings.json` values as potentially sensitive; do not commit real Jira tokens or cluster-specific settings.