Skip to content

Structured Metadata for Better Context #8

@mheadd

Description

@mheadd

Summary

Add Response Metadata

// In internal/mcp/handlers.go
type SearchParksOutput struct {
    Parks    []models.Park    `json:"parks"`
    Metadata ResponseMetadata `json:"metadata"` // NEW
}

type ResponseMetadata struct {
    TotalResults     int       `json:"total_results"`
    ReturnedResults  int       `json:"returned_results"`
    CacheHit         bool      `json:"cache_hit"`
    DataFreshness    string    `json:"data_freshness"` // "real-time", "cached-1h", etc.
    Suggestions      []string  `json:"suggestions,omitempty"` // "Try searching by state", etc.
    RelatedQueries   []string  `json:"related_queries,omitempty"` // "Get weather for this park"
}

LLM-Friendly Suggestions

func generateSuggestions(results []models.Park, query string) []string {
    suggestions := []string{}
    
    if len(results) > 5 {
        suggestions = append(suggestions, 
            "Large result set - consider narrowing by state or activity")
    }
    
    if len(results) > 0 {
        suggestions = append(suggestions,
            fmt.Sprintf("Get detailed info: use park code '%s'", results[0].ParkCode),
            fmt.Sprintf("Check alerts: use get_park_alerts for '%s'", results[0].Name),
        )
    }
    
    return suggestions
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions