Add getPeople

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2025-11-20 19:23:40 +01:00
parent 85b7c1cd7b
commit deb656d95e
4 changed files with 61 additions and 0 deletions

View File

@@ -137,3 +137,16 @@ func (r *Resolver) ListPeopleTool(ctx context.Context, req *mcp.CallToolRequest,
return nil, types.NewListPeopleOutput(page), nil
}
func (r *Resolver) GetPeopleTool(ctx context.Context, req *mcp.CallToolRequest, input *types.GetPeopleInput) (*mcp.CallToolResult, types.GetPeopleOutput, error) {
prb := r.ProboService(ctx, input.ID.TenantID())
people, err := prb.Peoples.Get(ctx, input.ID)
if err != nil {
return nil, types.GetPeopleOutput{}, fmt.Errorf("failed to get people: %w", err)
}
return nil, types.GetPeopleOutput{
People: types.NewPeople(people),
}, nil
}

View File

@@ -15,6 +15,7 @@ type ResolverInterface interface {
ListPeopleTool(ctx context.Context, req *mcp.CallToolRequest, input *types.ListPeopleInput) (*mcp.CallToolResult, types.ListPeopleOutput, error)
AddVendorTool(ctx context.Context, req *mcp.CallToolRequest, input *types.AddVendorInput) (*mcp.CallToolResult, types.AddVendorOutput, error)
UpdateVendorTool(ctx context.Context, req *mcp.CallToolRequest, input *types.UpdateVendorInput) (*mcp.CallToolResult, types.UpdateVendorOutput, error)
GetPeopleTool(ctx context.Context, req *mcp.CallToolRequest, input *types.GetPeopleInput) (*mcp.CallToolResult, types.GetPeopleOutput, error)
}
// New creates a new MCP server instance with all handlers registered.
@@ -84,4 +85,14 @@ func registerToolHandlers(server *mcp.Server, resolver ResolverInterface) {
},
resolver.UpdateVendorTool,
)
mcp.AddTool(
server,
&mcp.Tool{
Name: "getPeople",
Description: "Get a people by ID",
InputSchema: types.GetPeopleToolInputSchema,
OutputSchema: types.GetPeopleToolOutputSchema,
},
resolver.GetPeopleTool,
)
}

View File

@@ -335,6 +335,23 @@ components:
vendor:
$ref: "#/components/schemas/Vendor"
GetPeopleInput:
type: object
required:
- id
properties:
id:
$ref: "#/components/schemas/GID"
description: People ID
GetPeopleOutput:
type: object
required:
- people
properties:
people:
$ref: "#/components/schemas/People"
tools:
- name: listOrganizations
description: List all organizations the user has access to
@@ -371,3 +388,10 @@ tools:
$ref: "#/components/schemas/UpdateVendorInput"
outputSchema:
$ref: "#/components/schemas/UpdateVendorOutput"
- name: getPeople
description: Get a people by ID
readonly: true
inputSchema:
$ref: "#/components/schemas/GetPeopleInput"
outputSchema:
$ref: "#/components/schemas/GetPeopleOutput"

View File

@@ -14,6 +14,8 @@ import (
var (
AddVendorToolInputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["organization_id","name"],"properties":{"created_at":{"type":"string","description":"Creation timestamp","format":"date-time"},"description":{"type":"string","description":"Vendor description"},"name":{"type":"string","description":"Vendor name"},"organization_id":{"type":"string","format":"string"},"updated_at":{"type":"string","description":"Update timestamp","format":"date-time"}}}`)
AddVendorToolOutputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["vendor"],"properties":{"vendor":{"type":"object","required":["id","name","organization_id","created_at","updated_at"],"properties":{"created_at":{"type":"string","description":"Creation timestamp","format":"date-time"},"description":{"description":"Vendor description"},"id":{"type":"string","format":"string"},"name":{"type":"string","description":"Vendor name"},"organization_id":{"type":"string","format":"string"},"updated_at":{"type":"string","description":"Update timestamp","format":"date-time"}}}}}`)
GetPeopleToolInputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["id"],"properties":{"id":{"type":"string","format":"string"}}}`)
GetPeopleToolOutputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["people"],"properties":{"people":{"type":"object","required":["id","organization_id","full_name","primary_email_address","additional_email_addresses","kind","created_at","updated_at"],"properties":{"additional_email_addresses":{"type":"array","description":"Additional email addresses","items":{"type":"string"}},"contract_end_date":{"description":"Contract end date","format":"date-time"},"contract_start_date":{"description":"Contract start date","format":"date-time"},"created_at":{"type":"string","description":"Creation timestamp","format":"date-time"},"full_name":{"type":"string","description":"Full name"},"id":{"type":"string","format":"string"},"kind":{"type":"string","enum":["EMPLOYEE","CONTRACTOR","SERVICE_ACCOUNT"]},"organization_id":{"type":"string","format":"string"},"position":{"description":"Position"},"primary_email_address":{"type":"string","description":"Primary email address"},"updated_at":{"type":"string","description":"Update timestamp","format":"date-time"}}}}}`)
ListOrganizationsToolInputSchema = mcp.MustUnmarshalSchema(`{"type":"object","properties":{"organization_id":{"type":"string","format":"string"}}}`)
ListOrganizationsToolOutputSchema = mcp.MustUnmarshalSchema(`{"type":"object","properties":{"organizations":{"type":"array","items":{"type":"object","required":["id","name","description","created_at","updated_at"],"properties":{"created_at":{"type":"string","description":"Creation timestamp","format":"date-time"},"description":{"description":"Organization description"},"id":{"type":"string","format":"string"},"name":{"type":"string","description":"Organization name"},"updated_at":{"type":"string","description":"Update timestamp","format":"date-time"}}}}}}`)
ListPeopleToolInputSchema = mcp.MustUnmarshalSchema(`{"type":"object","required":["organization_id"],"properties":{"cursor":{"type":"string","format":"string"},"filter":{"type":"object","properties":{"exclude_contract_ended":{"type":"boolean","description":"Exclude people with ended contracts"}}},"order_by":{"type":"object","required":["field","direction"],"properties":{"direction":{"type":"string","enum":["asc","desc"]},"field":{"type":"string","enum":["CREATED_AT","FULL_NAME","KIND"]}}},"organization_id":{"type":"string","format":"string"},"size":{"type":"integer","description":"Page size"}}}`)
@@ -43,6 +45,17 @@ type AddVendorOutput struct {
Vendor *Vendor `json:"vendor"`
}
// GetPeopleInput represents the schema
type GetPeopleInput struct {
// People ID
ID gid.GID `json:"id"`
}
// GetPeopleOutput represents the schema
type GetPeopleOutput struct {
People *People `json:"people"`
}
// ListOrganizationsInput represents the schema
type ListOrganizationsInput struct {
// Organization ID