Skip to content

Commit 22c16b1

Browse files
Saranya-jenaHarness
authored andcommitted
chore: [ML-1194]: Fixed Issue with harness-context fields not getting passed as argument to devops agent (#38)
* chore: [ML-1194]: Fixed Issue with harness-context fields not getting passed as argument to devops agent Signed-off-by: Saranya-jena <[email protected]> * chore: [ML-1194]: Fixed Issue with harness-context fields not getting passed as argument to devops agent Signed-off-by: Saranya-jena <[email protected]>
1 parent a5b3569 commit 22c16b1

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,35 @@ Environment variables are prefixed with `HARNESS_`:
385385

386386
The server uses a Harness API key for authentication. This can be set via the `HARNESS_API_KEY` environment variable.
387387

388+
## Notes for Local Testing
389+
390+
There might be certain tools that are not added in external mode or vice-versa, for local testing, following changes in `pkg/harness/tools.go` need to be done in mcp-server code to enable that certain tool in both internal and external modes.
391+
392+
```
393+
baseURL := "https://localhost:8000"
394+
secret := <SERVICE_SECRET>
395+
```
396+
397+
### Example
398+
399+
```
400+
// registerGenai registers the genai toolset
401+
func registerGenai(config *config.Config, tsg *toolsets.ToolsetGroup) error {
402+
403+
// Determine the base URL and secret for genai service
404+
baseURL := "http://localhost:8000"
405+
secret := <GENAI_SECRET>
406+
407+
// Create base client for genai with the default timeout
408+
c, err := createClient(baseURL, config, secret, defaultGenaiTimeout)
409+
if err != nil {
410+
return err
411+
}
412+
.
413+
.
414+
.
415+
```
416+
388417
## Debugging
389418

390419
Since MCP servers run over stdio, debugging can be challenging. For the best debugging experience, we strongly recommend using the [MCP Inspector](https://github.com/modelcontextprotocol/inspector).

pkg/harness/genai.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ func AIDevOpsAgentTool(config *config.Config, client *client.GenaiService) (tool
8888
interactionID, _ := OptionalParam[string](request, "interaction_id")
8989
contextRaw, _ := OptionalParam[[]any](request, "context")
9090
conversationRaw, _ := OptionalParam[[]any](request, "conversation_raw")
91+
harnessContextRaw, _ := OptionalParam[map[string]interface{}](request, "harness_context")
9192
stream := true // default value
9293
if streamArg, ok := request.Params.Arguments["stream"].(bool); ok {
9394
stream = streamArg
@@ -124,6 +125,19 @@ func AIDevOpsAgentTool(config *config.Config, client *client.GenaiService) (tool
124125
ProjectID: scope.ProjectID,
125126
}
126127

128+
// Override with values from request if provided
129+
if harnessContextRaw != nil {
130+
if accountID, ok := harnessContextRaw["accountID"].(string); ok && accountID != "" {
131+
harnessContext.AccountID = accountID
132+
}
133+
if orgID, ok := harnessContextRaw["orgID"].(string); ok && orgID != "" {
134+
harnessContext.OrgID = orgID
135+
}
136+
if projectID, ok := harnessContextRaw["projectID"].(string); ok && projectID != "" {
137+
harnessContext.ProjectID = projectID
138+
}
139+
}
140+
127141
// Generate or use provided IDs
128142
var finalConversationID, finalInteractionID string
129143

0 commit comments

Comments
 (0)