Skip to main content
Glama
python.go2.12 kB
package parser import ( tree_sitter "github.com/tree-sitter/go-tree-sitter" tree_sitter_python "github.com/tree-sitter/tree-sitter-python/bindings/go" ) var PythonSpec = &LanguageSpec{ NamedChunks: map[string]NamedChunkExtractor{ "function_definition": { NameQuery: `(function_definition name: (identifier) @name)`, }, "class_definition": { NameQuery: `(class_definition name: (identifier) @name)`, }, "decorated_definition": { NameQuery: `(decorated_definition definition: [ (function_definition name: (identifier) @name) (class_definition name: (identifier) @name) ])`, SummaryNodeQuery: `(decorated_definition definition: [ (function_definition) @summary (class_definition) @summary ])`, }, "expression_statement": { NameQuery: `(expression_statement (assignment left: (identifier) @name))`, }, }, ExtractChildrenIn: []string{ "class_definition", "block", }, FoldIntoNextNode: []string{"comment"}, SkipTypes: []string{ // Imports pollute search results "import_statement", "import_from_statement", // Skip punctuation and keyword tokens ":", "class", "def", "pass", "pass_statement", // Skip identifier tokens (they're part of declarations) "identifier", // Skip argument lists and other syntax elements "argument_list", // Skip container nodes (but still extract their children) "block", }, FileTypeRules: []FileTypeRule{ {Pattern: "**/test*.py", Type: FileTypeTests}, {Pattern: "**/*_test.py", Type: FileTypeTests}, {Pattern: "**/__pycache__/**", Type: FileTypeIgnore}, {Pattern: "**/venv/**", Type: FileTypeIgnore}, {Pattern: "**/.venv/**", Type: FileTypeIgnore}, {Pattern: "**/env/**", Type: FileTypeIgnore}, {Pattern: "**/.env/**", Type: FileTypeIgnore}, {Pattern: "**/site-packages/**", Type: FileTypeIgnore}, }, } func NewPythonParser(workspaceRoot string) (*Parser, error) { parser := tree_sitter.NewParser() parser.SetLanguage(tree_sitter.NewLanguage(tree_sitter_python.Language())) return &Parser{ workspaceRoot: workspaceRoot, parser: parser, spec: PythonSpec, }, 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/st3v3nmw/sourcerer-mcp'

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