Skip to main content
Glama

protolint-mcp

by yoheimuta
externalRule.go1.88 kB
package plugin import ( "path/filepath" "github.com/yoheimuta/protolint/internal/addon/plugin/shared" "github.com/yoheimuta/go-protoparser/v4/parser" "github.com/yoheimuta/go-protoparser/v4/parser/meta" "github.com/yoheimuta/protolint/internal/addon/plugin/proto" "github.com/yoheimuta/protolint/linter/report" "github.com/yoheimuta/protolint/linter/rule" ) // externalRule represents a customized rule that works as a plugin. type externalRule struct { id string purpose string client shared.RuleSet severity rule.Severity } func newExternalRule( id string, purpose string, client shared.RuleSet, severity rule.Severity, ) externalRule { return externalRule{ id: id, purpose: purpose, client: client, severity: severity, } } // ID returns the ID of this rule. func (r externalRule) ID() string { return r.id } // Purpose returns the purpose of this rule. func (r externalRule) Purpose() string { return r.purpose } // IsOfficial decides whether or not this rule belongs to the official guide. func (r externalRule) IsOfficial() bool { return true } // Severity returns the severity of a rule (note, warning, error) func (r externalRule) Severity() rule.Severity { return r.severity } // Apply applies the rule to the proto. func (r externalRule) Apply(p *parser.Proto) ([]report.Failure, error) { relPath := p.Meta.Filename absPath, err := filepath.Abs(relPath) if err != nil { return nil, err } resp, err := r.client.Apply(&proto.ApplyRequest{ Id: r.id, Path: absPath, }) if err != nil { return nil, err } var fs []report.Failure for _, f := range resp.Failures { fs = append(fs, report.Failuref(meta.Position{ Filename: relPath, Offset: int(f.Pos.Offset), Line: int(f.Pos.Line), Column: int(f.Pos.Column), }, r.id, string(r.severity), "%s", f.Message)) } return fs, nil }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yoheimuta/protolint'

If you have feedback or need assistance with the MCP directory API, please join our Discord server