ibge-br-mcp 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +91 -0
- package/.github/workflows/publish.yml +118 -0
- package/CHANGELOG.md +171 -0
- package/CONTRIBUTING.md +285 -0
- package/LICENSE +21 -0
- package/README.md +499 -0
- package/README.pt-BR.md +502 -0
- package/dist/cache.d.ts +57 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +115 -0
- package/dist/cache.js.map +1 -0
- package/dist/config.d.ts +152 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +324 -0
- package/dist/config.js.map +1 -0
- package/dist/errors.d.ts +42 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +130 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +582 -0
- package/dist/index.js.map +1 -0
- package/dist/metrics.d.ts +103 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +269 -0
- package/dist/metrics.js.map +1 -0
- package/dist/retry.d.ts +47 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +125 -0
- package/dist/retry.js.map +1 -0
- package/dist/tools/bcb.d.ts +50 -0
- package/dist/tools/bcb.d.ts.map +1 -0
- package/dist/tools/bcb.js +298 -0
- package/dist/tools/bcb.js.map +1 -0
- package/dist/tools/calendario.d.ts +56 -0
- package/dist/tools/calendario.d.ts.map +1 -0
- package/dist/tools/calendario.js +174 -0
- package/dist/tools/calendario.js.map +1 -0
- package/dist/tools/censo.d.ts +50 -0
- package/dist/tools/censo.d.ts.map +1 -0
- package/dist/tools/censo.js +384 -0
- package/dist/tools/censo.js.map +1 -0
- package/dist/tools/cidades.d.ts +50 -0
- package/dist/tools/cidades.d.ts.map +1 -0
- package/dist/tools/cidades.js +334 -0
- package/dist/tools/cidades.js.map +1 -0
- package/dist/tools/cnae.d.ts +44 -0
- package/dist/tools/cnae.d.ts.map +1 -0
- package/dist/tools/cnae.js +280 -0
- package/dist/tools/cnae.js.map +1 -0
- package/dist/tools/comparar.d.ts +38 -0
- package/dist/tools/comparar.d.ts.map +1 -0
- package/dist/tools/comparar.js +324 -0
- package/dist/tools/comparar.js.map +1 -0
- package/dist/tools/datasaude.d.ts +50 -0
- package/dist/tools/datasaude.d.ts.map +1 -0
- package/dist/tools/datasaude.js +292 -0
- package/dist/tools/datasaude.js.map +1 -0
- package/dist/tools/estados.d.ts +32 -0
- package/dist/tools/estados.d.ts.map +1 -0
- package/dist/tools/estados.js +101 -0
- package/dist/tools/estados.js.map +1 -0
- package/dist/tools/geocodigo.d.ts +38 -0
- package/dist/tools/geocodigo.d.ts.map +1 -0
- package/dist/tools/geocodigo.js +350 -0
- package/dist/tools/geocodigo.js.map +1 -0
- package/dist/tools/index.d.ts +28 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +421 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/indicadores.d.ts +56 -0
- package/dist/tools/indicadores.d.ts.map +1 -0
- package/dist/tools/indicadores.js +343 -0
- package/dist/tools/indicadores.js.map +1 -0
- package/dist/tools/localidade.d.ts +32 -0
- package/dist/tools/localidade.d.ts.map +1 -0
- package/dist/tools/localidade.js +170 -0
- package/dist/tools/localidade.js.map +1 -0
- package/dist/tools/malhas-tema.d.ts +50 -0
- package/dist/tools/malhas-tema.d.ts.map +1 -0
- package/dist/tools/malhas-tema.js +284 -0
- package/dist/tools/malhas-tema.js.map +1 -0
- package/dist/tools/malhas.d.ts +56 -0
- package/dist/tools/malhas.d.ts.map +1 -0
- package/dist/tools/malhas.js +286 -0
- package/dist/tools/malhas.js.map +1 -0
- package/dist/tools/municipios.d.ts +38 -0
- package/dist/tools/municipios.d.ts.map +1 -0
- package/dist/tools/municipios.js +111 -0
- package/dist/tools/municipios.js.map +1 -0
- package/dist/tools/nomes.d.ts +95 -0
- package/dist/tools/nomes.d.ts.map +1 -0
- package/dist/tools/nomes.js +232 -0
- package/dist/tools/nomes.js.map +1 -0
- package/dist/tools/noticias.d.ts +62 -0
- package/dist/tools/noticias.d.ts.map +1 -0
- package/dist/tools/noticias.js +136 -0
- package/dist/tools/noticias.js.map +1 -0
- package/dist/tools/paises.d.ts +50 -0
- package/dist/tools/paises.d.ts.map +1 -0
- package/dist/tools/paises.js +240 -0
- package/dist/tools/paises.js.map +1 -0
- package/dist/tools/pesquisas.d.ts +32 -0
- package/dist/tools/pesquisas.d.ts.map +1 -0
- package/dist/tools/pesquisas.js +166 -0
- package/dist/tools/pesquisas.js.map +1 -0
- package/dist/tools/populacao.d.ts +31 -0
- package/dist/tools/populacao.d.ts.map +1 -0
- package/dist/tools/populacao.js +109 -0
- package/dist/tools/populacao.js.map +1 -0
- package/dist/tools/sidra-metadados.d.ts +38 -0
- package/dist/tools/sidra-metadados.d.ts.map +1 -0
- package/dist/tools/sidra-metadados.js +222 -0
- package/dist/tools/sidra-metadados.js.map +1 -0
- package/dist/tools/sidra-tabelas.d.ts +38 -0
- package/dist/tools/sidra-tabelas.d.ts.map +1 -0
- package/dist/tools/sidra-tabelas.js +134 -0
- package/dist/tools/sidra-tabelas.js.map +1 -0
- package/dist/tools/sidra.d.ts +66 -0
- package/dist/tools/sidra.d.ts.map +1 -0
- package/dist/tools/sidra.js +225 -0
- package/dist/tools/sidra.js.map +1 -0
- package/dist/tools/vizinhos.d.ts +44 -0
- package/dist/tools/vizinhos.d.ts.map +1 -0
- package/dist/tools/vizinhos.js +262 -0
- package/dist/tools/vizinhos.js.map +1 -0
- package/dist/types.d.ts +274 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +29 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/formatters.d.ts +84 -0
- package/dist/utils/formatters.d.ts.map +1 -0
- package/dist/utils/formatters.js +278 -0
- package/dist/utils/formatters.js.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/validation.d.ts +42 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +237 -0
- package/dist/validation.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, master]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main, master]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build-and-test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
node-version: [18.x, 20.x, 22.x]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout repository
|
|
19
|
+
uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Setup Node.js ${{ matrix.node-version }}
|
|
22
|
+
uses: actions/setup-node@v4
|
|
23
|
+
with:
|
|
24
|
+
node-version: ${{ matrix.node-version }}
|
|
25
|
+
cache: "npm"
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: npm ci
|
|
29
|
+
|
|
30
|
+
- name: Run linter
|
|
31
|
+
run: npm run lint
|
|
32
|
+
|
|
33
|
+
- name: Check formatting
|
|
34
|
+
run: npm run format:check
|
|
35
|
+
|
|
36
|
+
- name: Build
|
|
37
|
+
run: npm run build
|
|
38
|
+
|
|
39
|
+
- name: Run tests
|
|
40
|
+
run: npm test
|
|
41
|
+
|
|
42
|
+
- name: Run tests with coverage
|
|
43
|
+
if: matrix.node-version == '20.x'
|
|
44
|
+
run: npm run test:coverage
|
|
45
|
+
|
|
46
|
+
- name: Upload coverage reports
|
|
47
|
+
if: matrix.node-version == '20.x'
|
|
48
|
+
uses: codecov/codecov-action@v4
|
|
49
|
+
with:
|
|
50
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
51
|
+
fail_ci_if_error: false
|
|
52
|
+
continue-on-error: true
|
|
53
|
+
|
|
54
|
+
type-check:
|
|
55
|
+
runs-on: ubuntu-latest
|
|
56
|
+
|
|
57
|
+
steps:
|
|
58
|
+
- name: Checkout repository
|
|
59
|
+
uses: actions/checkout@v4
|
|
60
|
+
|
|
61
|
+
- name: Setup Node.js
|
|
62
|
+
uses: actions/setup-node@v4
|
|
63
|
+
with:
|
|
64
|
+
node-version: "20.x"
|
|
65
|
+
cache: "npm"
|
|
66
|
+
|
|
67
|
+
- name: Install dependencies
|
|
68
|
+
run: npm ci
|
|
69
|
+
|
|
70
|
+
- name: Type check
|
|
71
|
+
run: npx tsc --noEmit
|
|
72
|
+
|
|
73
|
+
security:
|
|
74
|
+
runs-on: ubuntu-latest
|
|
75
|
+
|
|
76
|
+
steps:
|
|
77
|
+
- name: Checkout repository
|
|
78
|
+
uses: actions/checkout@v4
|
|
79
|
+
|
|
80
|
+
- name: Setup Node.js
|
|
81
|
+
uses: actions/setup-node@v4
|
|
82
|
+
with:
|
|
83
|
+
node-version: "20.x"
|
|
84
|
+
cache: "npm"
|
|
85
|
+
|
|
86
|
+
- name: Install dependencies
|
|
87
|
+
run: npm ci
|
|
88
|
+
|
|
89
|
+
- name: Run npm audit
|
|
90
|
+
run: npm audit --audit-level=high
|
|
91
|
+
continue-on-error: true
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
name: Publish to npm
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
inputs:
|
|
8
|
+
dry-run:
|
|
9
|
+
description: "Dry run (do not publish)"
|
|
10
|
+
required: false
|
|
11
|
+
default: "false"
|
|
12
|
+
type: boolean
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
build:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- name: Checkout repository
|
|
20
|
+
uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
- name: Setup Node.js
|
|
23
|
+
uses: actions/setup-node@v4
|
|
24
|
+
with:
|
|
25
|
+
node-version: "20.x"
|
|
26
|
+
cache: "npm"
|
|
27
|
+
registry-url: "https://registry.npmjs.org"
|
|
28
|
+
|
|
29
|
+
- name: Install dependencies
|
|
30
|
+
run: npm ci
|
|
31
|
+
|
|
32
|
+
- name: Run linter
|
|
33
|
+
run: npm run lint
|
|
34
|
+
|
|
35
|
+
- name: Run tests
|
|
36
|
+
run: npm test
|
|
37
|
+
|
|
38
|
+
- name: Build
|
|
39
|
+
run: npm run build
|
|
40
|
+
|
|
41
|
+
- name: Verify package contents
|
|
42
|
+
run: npm pack --dry-run
|
|
43
|
+
|
|
44
|
+
- name: Check package version
|
|
45
|
+
id: version
|
|
46
|
+
run: |
|
|
47
|
+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
|
|
48
|
+
echo "version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
|
|
49
|
+
echo "Package version: $PACKAGE_VERSION"
|
|
50
|
+
|
|
51
|
+
publish:
|
|
52
|
+
needs: build
|
|
53
|
+
runs-on: ubuntu-latest
|
|
54
|
+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.dry-run == 'false')
|
|
55
|
+
|
|
56
|
+
steps:
|
|
57
|
+
- name: Checkout repository
|
|
58
|
+
uses: actions/checkout@v4
|
|
59
|
+
|
|
60
|
+
- name: Setup Node.js
|
|
61
|
+
uses: actions/setup-node@v4
|
|
62
|
+
with:
|
|
63
|
+
node-version: "20.x"
|
|
64
|
+
cache: "npm"
|
|
65
|
+
registry-url: "https://registry.npmjs.org"
|
|
66
|
+
|
|
67
|
+
- name: Install dependencies
|
|
68
|
+
run: npm ci
|
|
69
|
+
|
|
70
|
+
- name: Build
|
|
71
|
+
run: npm run build
|
|
72
|
+
|
|
73
|
+
- name: Publish to npm
|
|
74
|
+
run: npm publish --access public
|
|
75
|
+
env:
|
|
76
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
77
|
+
|
|
78
|
+
- name: Create publish summary
|
|
79
|
+
run: |
|
|
80
|
+
echo "## 📦 Package Published" >> $GITHUB_STEP_SUMMARY
|
|
81
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
82
|
+
echo "**Package:** ibge-br-mcp" >> $GITHUB_STEP_SUMMARY
|
|
83
|
+
echo "**Version:** $(node -p "require('./package.json').version")" >> $GITHUB_STEP_SUMMARY
|
|
84
|
+
echo "**Registry:** https://www.npmjs.com/package/ibge-br-mcp" >> $GITHUB_STEP_SUMMARY
|
|
85
|
+
|
|
86
|
+
dry-run:
|
|
87
|
+
needs: build
|
|
88
|
+
runs-on: ubuntu-latest
|
|
89
|
+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.dry-run == 'true'
|
|
90
|
+
|
|
91
|
+
steps:
|
|
92
|
+
- name: Checkout repository
|
|
93
|
+
uses: actions/checkout@v4
|
|
94
|
+
|
|
95
|
+
- name: Setup Node.js
|
|
96
|
+
uses: actions/setup-node@v4
|
|
97
|
+
with:
|
|
98
|
+
node-version: "20.x"
|
|
99
|
+
cache: "npm"
|
|
100
|
+
registry-url: "https://registry.npmjs.org"
|
|
101
|
+
|
|
102
|
+
- name: Install dependencies
|
|
103
|
+
run: npm ci
|
|
104
|
+
|
|
105
|
+
- name: Build
|
|
106
|
+
run: npm run build
|
|
107
|
+
|
|
108
|
+
- name: Dry run publish
|
|
109
|
+
run: |
|
|
110
|
+
echo "## 🧪 Dry Run - Package would be published" >> $GITHUB_STEP_SUMMARY
|
|
111
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
112
|
+
echo "**Package:** ibge-br-mcp" >> $GITHUB_STEP_SUMMARY
|
|
113
|
+
echo "**Version:** $(node -p "require('./package.json').version")" >> $GITHUB_STEP_SUMMARY
|
|
114
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
115
|
+
echo "### Package Contents:" >> $GITHUB_STEP_SUMMARY
|
|
116
|
+
echo '```' >> $GITHUB_STEP_SUMMARY
|
|
117
|
+
npm pack --dry-run 2>&1 >> $GITHUB_STEP_SUMMARY
|
|
118
|
+
echo '```' >> $GITHUB_STEP_SUMMARY
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to the IBGE MCP Server will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.9.0] - 2024
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Países tool** (`ibge_paises`): Query international country data from IBGE
|
|
12
|
+
- List all countries (UN M49 methodology)
|
|
13
|
+
- Search countries by name
|
|
14
|
+
- Filter by region/continent (Americas, Europe, Africa, Asia, Oceania)
|
|
15
|
+
- Get detailed country information (area, languages, currency, indicators)
|
|
16
|
+
- **Cidades tool** (`ibge_cidades`): Query municipal indicators (similar to Cidades@IBGE portal)
|
|
17
|
+
- Municipal panorama with key indicators (population, GDP, HDI, etc.)
|
|
18
|
+
- Historical indicator data over time
|
|
19
|
+
- Research and indicator listing
|
|
20
|
+
- **Test suite**: Comprehensive unit tests for paises and cidades tools (36 new tests)
|
|
21
|
+
- **Package metadata**: Added homepage and bugs.url fields
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
- All 23 tool descriptions standardized to English for MCP catalog compatibility
|
|
25
|
+
- README completely rewritten in English with comprehensive documentation
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
- Phase 4 tools (ibge_paises, ibge_cidades) now properly registered in main server
|
|
29
|
+
- SERVER_VERSION updated to 1.9.0
|
|
30
|
+
- Fixed 14 ESLint non-null assertion warnings using nullish coalescing
|
|
31
|
+
|
|
32
|
+
## [1.8.0] - 2024
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
- **LICENSE**: MIT license file
|
|
36
|
+
- **.npmignore**: Proper npm package exclusions
|
|
37
|
+
|
|
38
|
+
### Fixed
|
|
39
|
+
- All linter warnings resolved (0 warnings)
|
|
40
|
+
|
|
41
|
+
## [1.7.0] - 2024
|
|
42
|
+
|
|
43
|
+
### Added
|
|
44
|
+
- **Testing framework**: Vitest with comprehensive test suite
|
|
45
|
+
- 173 unit tests covering validation, cache, errors, retry, and formatters
|
|
46
|
+
- Test coverage configuration (v8 provider)
|
|
47
|
+
- Test timeout settings for network operations
|
|
48
|
+
|
|
49
|
+
## [1.6.0] - 2024
|
|
50
|
+
|
|
51
|
+
### Added
|
|
52
|
+
- **Retry mechanism**: Exponential backoff for network failures
|
|
53
|
+
- Configurable retry count and delay
|
|
54
|
+
- Custom retry conditions
|
|
55
|
+
- Retry utility for fetch operations
|
|
56
|
+
|
|
57
|
+
## [1.5.0] - 2024
|
|
58
|
+
|
|
59
|
+
### Added
|
|
60
|
+
- **Centralized validation**: Input validation with descriptive error messages
|
|
61
|
+
- IBGE code validation (regions, states, municipalities, districts)
|
|
62
|
+
- UF normalization (abbreviation to code conversion)
|
|
63
|
+
- Date format validation
|
|
64
|
+
- Period validation (years, ranges, quarters)
|
|
65
|
+
- Territorial level validation
|
|
66
|
+
- CNAE code validation
|
|
67
|
+
|
|
68
|
+
### Changed
|
|
69
|
+
- All tools now use centralized validation
|
|
70
|
+
|
|
71
|
+
## [1.4.0] - 2024
|
|
72
|
+
|
|
73
|
+
### Added
|
|
74
|
+
- **Centralized error handling**: Consistent error messages across all tools
|
|
75
|
+
- HTTP error parsing with helpful suggestions
|
|
76
|
+
- Validation error formatting
|
|
77
|
+
- Tool-specific error context
|
|
78
|
+
|
|
79
|
+
### Changed
|
|
80
|
+
- All tools now use centralized error handling
|
|
81
|
+
|
|
82
|
+
## [1.3.0] - 2024
|
|
83
|
+
|
|
84
|
+
### Added
|
|
85
|
+
- **ESLint + Prettier**: Code quality and formatting
|
|
86
|
+
- TypeScript-aware linting rules
|
|
87
|
+
- Consistent code formatting
|
|
88
|
+
- Pre-configured for ES modules
|
|
89
|
+
|
|
90
|
+
## [1.2.0] - 2024
|
|
91
|
+
|
|
92
|
+
### Added
|
|
93
|
+
- **Performance metrics**: Request tracking and performance monitoring
|
|
94
|
+
- Request duration tracking
|
|
95
|
+
- API endpoint categorization
|
|
96
|
+
- Success/failure statistics
|
|
97
|
+
- Average response times
|
|
98
|
+
|
|
99
|
+
### Changed
|
|
100
|
+
- All tools now report metrics via `withMetrics` wrapper
|
|
101
|
+
|
|
102
|
+
## [1.1.0] - 2024
|
|
103
|
+
|
|
104
|
+
### Added
|
|
105
|
+
- **Centralized utilities**: Common formatting functions
|
|
106
|
+
- `formatNumber`: Locale-aware number formatting
|
|
107
|
+
- `truncate`: String truncation with ellipsis
|
|
108
|
+
- `createMarkdownTable`: Markdown table generation
|
|
109
|
+
- `buildQueryString`: URL query string construction
|
|
110
|
+
|
|
111
|
+
### Changed
|
|
112
|
+
- All tools migrated to use centralized utilities
|
|
113
|
+
- Consistent number and date formatting across all tools
|
|
114
|
+
|
|
115
|
+
## [1.0.0] - 2024
|
|
116
|
+
|
|
117
|
+
### Added
|
|
118
|
+
- **Cache system**: In-memory caching with TTL
|
|
119
|
+
- Configurable TTL levels (STATIC, MEDIUM, SHORT, REALTIME)
|
|
120
|
+
- Cache key generation with parameter normalization
|
|
121
|
+
- Automatic cache expiration
|
|
122
|
+
|
|
123
|
+
### Changed
|
|
124
|
+
- All tools now use caching for improved performance
|
|
125
|
+
|
|
126
|
+
## [0.9.0] - 2024
|
|
127
|
+
|
|
128
|
+
### Added
|
|
129
|
+
- **Phase 3 tools**:
|
|
130
|
+
- `ibge_malhas_tematicas`: Thematic meshes (health regions, metropolitan areas)
|
|
131
|
+
- `bcb_inflacao`: Central Bank inflation data (IPCA, IGP-M, INPC)
|
|
132
|
+
- `datasaude`: Health indicators (mortality, life expectancy, sanitation)
|
|
133
|
+
- `ibge_indicadores`: Economic and social indicators (GDP, unemployment, IPCA)
|
|
134
|
+
|
|
135
|
+
## [0.8.0] - 2024
|
|
136
|
+
|
|
137
|
+
### Added
|
|
138
|
+
- **Phase 2 tools**:
|
|
139
|
+
- `ibge_noticias`: IBGE news and releases
|
|
140
|
+
- `ibge_calendario`: IBGE release calendar
|
|
141
|
+
- `ibge_sidra_metadados`: SIDRA table metadata
|
|
142
|
+
- `ibge_pesquisas`: IBGE research surveys
|
|
143
|
+
- `ibge_sidra_tabelas`: SIDRA table search
|
|
144
|
+
- `ibge_censo`: Census data (2022 and 2010)
|
|
145
|
+
- `ibge_cnae`: CNAE economic activity codes
|
|
146
|
+
|
|
147
|
+
## [0.7.0] - 2024
|
|
148
|
+
|
|
149
|
+
### Added
|
|
150
|
+
- **Phase 1 tools**:
|
|
151
|
+
- `ibge_estados`: Brazilian states
|
|
152
|
+
- `ibge_municipios`: Municipalities by state
|
|
153
|
+
- `ibge_distritos`: Districts
|
|
154
|
+
- `ibge_localidades`: Localities search
|
|
155
|
+
- `ibge_regioes`: Geographic regions
|
|
156
|
+
- `ibge_sidra`: SIDRA data queries
|
|
157
|
+
- `ibge_nomes`: Name frequency statistics
|
|
158
|
+
- `ibge_ranking_nomes`: Name rankings
|
|
159
|
+
- `ibge_malhas`: Geographic meshes (GeoJSON/TopoJSON)
|
|
160
|
+
|
|
161
|
+
## [0.1.0] - 2024
|
|
162
|
+
|
|
163
|
+
### Added
|
|
164
|
+
- Initial MCP server setup
|
|
165
|
+
- Basic project structure
|
|
166
|
+
- TypeScript configuration
|
|
167
|
+
- Package configuration
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
For more details on each release, see the [commit history](https://github.com/SidneyBissoli/ibge-br-mcp/commits/main).
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
# Contributing to IBGE MCP Server
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to the IBGE MCP Server! This document provides guidelines and information for contributors.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Code of Conduct](#code-of-conduct)
|
|
8
|
+
- [Getting Started](#getting-started)
|
|
9
|
+
- [Development Setup](#development-setup)
|
|
10
|
+
- [Project Structure](#project-structure)
|
|
11
|
+
- [Adding New Tools](#adding-new-tools)
|
|
12
|
+
- [Testing](#testing)
|
|
13
|
+
- [Code Style](#code-style)
|
|
14
|
+
- [Submitting Changes](#submitting-changes)
|
|
15
|
+
|
|
16
|
+
## Code of Conduct
|
|
17
|
+
|
|
18
|
+
Please be respectful and constructive in all interactions. We welcome contributors of all experience levels.
|
|
19
|
+
|
|
20
|
+
## Getting Started
|
|
21
|
+
|
|
22
|
+
1. Fork the repository
|
|
23
|
+
2. Clone your fork: `git clone https://github.com/YOUR-USERNAME/ibge-br-mcp.git`
|
|
24
|
+
3. Create a feature branch: `git checkout -b feature/your-feature-name`
|
|
25
|
+
4. Make your changes
|
|
26
|
+
5. Submit a pull request
|
|
27
|
+
|
|
28
|
+
## Development Setup
|
|
29
|
+
|
|
30
|
+
### Prerequisites
|
|
31
|
+
|
|
32
|
+
- Node.js 18.0.0 or higher
|
|
33
|
+
- npm
|
|
34
|
+
|
|
35
|
+
### Installation
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
cd ibge-br-mcp
|
|
39
|
+
npm install
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Available Scripts
|
|
43
|
+
|
|
44
|
+
| Command | Description |
|
|
45
|
+
|---------|-------------|
|
|
46
|
+
| `npm run build` | Compile TypeScript to JavaScript |
|
|
47
|
+
| `npm run watch` | Watch mode for development |
|
|
48
|
+
| `npm run dev` | Build and run the server |
|
|
49
|
+
| `npm run lint` | Run ESLint |
|
|
50
|
+
| `npm run lint:fix` | Run ESLint with auto-fix |
|
|
51
|
+
| `npm run format` | Format code with Prettier |
|
|
52
|
+
| `npm run format:check` | Check formatting |
|
|
53
|
+
| `npm test` | Run tests |
|
|
54
|
+
| `npm run test:watch` | Run tests in watch mode |
|
|
55
|
+
| `npm run test:coverage` | Run tests with coverage report |
|
|
56
|
+
| `npm run inspector` | Open MCP Inspector |
|
|
57
|
+
|
|
58
|
+
## Project Structure
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
ibge-br-mcp/
|
|
62
|
+
├── src/
|
|
63
|
+
│ ├── index.ts # Main MCP server and tool registration
|
|
64
|
+
│ ├── types.ts # TypeScript type definitions
|
|
65
|
+
│ ├── cache.ts # In-memory caching system
|
|
66
|
+
│ ├── metrics.ts # Performance metrics tracking
|
|
67
|
+
│ ├── errors.ts # Error handling utilities
|
|
68
|
+
│ ├── validation.ts # Input validation functions
|
|
69
|
+
│ ├── retry.ts # Retry mechanism for network calls
|
|
70
|
+
│ ├── config.ts # Configuration and constants
|
|
71
|
+
│ ├── tools/ # Individual tool implementations
|
|
72
|
+
│ │ ├── estados.ts
|
|
73
|
+
│ │ ├── municipios.ts
|
|
74
|
+
│ │ ├── sidra.ts
|
|
75
|
+
│ │ └── ...
|
|
76
|
+
│ └── utils/ # Utility functions
|
|
77
|
+
│ ├── formatters.ts
|
|
78
|
+
│ └── index.ts
|
|
79
|
+
├── tests/ # Test files
|
|
80
|
+
│ ├── validation.test.ts
|
|
81
|
+
│ ├── cache.test.ts
|
|
82
|
+
│ └── ...
|
|
83
|
+
├── dist/ # Compiled JavaScript (generated)
|
|
84
|
+
└── package.json
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Adding New Tools
|
|
88
|
+
|
|
89
|
+
### Step 1: Create the Tool File
|
|
90
|
+
|
|
91
|
+
Create a new file in `src/tools/` with the following structure:
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
import { z } from "zod";
|
|
95
|
+
import { IBGE_API } from "../types.js";
|
|
96
|
+
import { cacheKey, CACHE_TTL, cachedFetch } from "../cache.js";
|
|
97
|
+
import { withMetrics } from "../metrics.js";
|
|
98
|
+
import { createMarkdownTable } from "../utils/index.js";
|
|
99
|
+
import { parseHttpError, ValidationErrors } from "../errors.js";
|
|
100
|
+
|
|
101
|
+
// Define the input schema using Zod
|
|
102
|
+
export const myToolSchema = z.object({
|
|
103
|
+
param1: z.string().describe("Description of param1"),
|
|
104
|
+
param2: z.number().optional().default(10).describe("Description of param2"),
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
export type MyToolInput = z.infer<typeof myToolSchema>;
|
|
108
|
+
|
|
109
|
+
// Implement the tool function
|
|
110
|
+
export async function myTool(input: MyToolInput): Promise<string> {
|
|
111
|
+
return withMetrics("my_tool", "api_category", async () => {
|
|
112
|
+
try {
|
|
113
|
+
// Your implementation here
|
|
114
|
+
const url = `${IBGE_API.LOCALIDADES}/...`;
|
|
115
|
+
const key = cacheKey(url);
|
|
116
|
+
const data = await cachedFetch<YourType>(url, key, CACHE_TTL.MEDIUM);
|
|
117
|
+
|
|
118
|
+
// Format and return results
|
|
119
|
+
return formatResults(data);
|
|
120
|
+
} catch (error) {
|
|
121
|
+
if (error instanceof Error) {
|
|
122
|
+
return parseHttpError(error, "my_tool", { param1: input.param1 });
|
|
123
|
+
}
|
|
124
|
+
return ValidationErrors.emptyResult("my_tool");
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Export tool definition
|
|
130
|
+
export const myToolTool = {
|
|
131
|
+
name: "my_tool",
|
|
132
|
+
description: `Description of your tool in English.
|
|
133
|
+
|
|
134
|
+
Features:
|
|
135
|
+
- Feature 1
|
|
136
|
+
- Feature 2
|
|
137
|
+
|
|
138
|
+
Examples:
|
|
139
|
+
- Example usage 1
|
|
140
|
+
- Example usage 2`,
|
|
141
|
+
inputSchema: myToolSchema,
|
|
142
|
+
handler: myTool,
|
|
143
|
+
};
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Step 2: Export from Tools Index
|
|
147
|
+
|
|
148
|
+
Add your export to `src/tools/index.ts`:
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
export * from "./my-tool.js";
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Step 3: Register in Main Server
|
|
155
|
+
|
|
156
|
+
Register the tool in `src/index.ts`:
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
import { myToolSchema, myTool } from "./tools/my-tool.js";
|
|
160
|
+
|
|
161
|
+
// In the tools section:
|
|
162
|
+
server.tool(
|
|
163
|
+
"my_tool",
|
|
164
|
+
`Tool description in English...`,
|
|
165
|
+
myToolSchema.shape,
|
|
166
|
+
async (args) => {
|
|
167
|
+
const result = await myTool(args);
|
|
168
|
+
return { content: [{ type: "text", text: result }] };
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Step 4: Add Tests
|
|
174
|
+
|
|
175
|
+
Create a test file `tests/my-tool.test.ts`:
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
import { describe, it, expect } from "vitest";
|
|
179
|
+
import { myToolSchema } from "../src/tools/my-tool.js";
|
|
180
|
+
|
|
181
|
+
describe("myToolSchema", () => {
|
|
182
|
+
it("should accept valid input", () => {
|
|
183
|
+
const result = myToolSchema.safeParse({ param1: "value" });
|
|
184
|
+
expect(result.success).toBe(true);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
// Add more tests...
|
|
188
|
+
});
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Testing
|
|
192
|
+
|
|
193
|
+
### Running Tests
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
# Run all tests
|
|
197
|
+
npm test
|
|
198
|
+
|
|
199
|
+
# Run tests in watch mode
|
|
200
|
+
npm run test:watch
|
|
201
|
+
|
|
202
|
+
# Run tests with coverage
|
|
203
|
+
npm run test:coverage
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Writing Tests
|
|
207
|
+
|
|
208
|
+
- Place test files in the `tests/` directory
|
|
209
|
+
- Name test files with `.test.ts` suffix
|
|
210
|
+
- Use descriptive test names
|
|
211
|
+
- Test both valid and invalid inputs
|
|
212
|
+
- Mock external API calls for integration tests
|
|
213
|
+
|
|
214
|
+
## Code Style
|
|
215
|
+
|
|
216
|
+
### ESLint & Prettier
|
|
217
|
+
|
|
218
|
+
The project uses ESLint and Prettier for code quality:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
# Check for linting issues
|
|
222
|
+
npm run lint
|
|
223
|
+
|
|
224
|
+
# Auto-fix linting issues
|
|
225
|
+
npm run lint:fix
|
|
226
|
+
|
|
227
|
+
# Format code
|
|
228
|
+
npm run format
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Style Guidelines
|
|
232
|
+
|
|
233
|
+
- Use TypeScript for all code
|
|
234
|
+
- Use ES modules (`.js` extension in imports)
|
|
235
|
+
- Prefer `const` over `let`
|
|
236
|
+
- Use descriptive variable and function names
|
|
237
|
+
- Add JSDoc comments for public functions
|
|
238
|
+
- Keep functions focused and small
|
|
239
|
+
- Use centralized utilities instead of inline implementations
|
|
240
|
+
|
|
241
|
+
### Tool Description Guidelines
|
|
242
|
+
|
|
243
|
+
- Write tool descriptions in English
|
|
244
|
+
- Include a brief summary
|
|
245
|
+
- List key features
|
|
246
|
+
- Provide usage examples
|
|
247
|
+
- Be concise but informative
|
|
248
|
+
|
|
249
|
+
## Submitting Changes
|
|
250
|
+
|
|
251
|
+
### Pull Request Process
|
|
252
|
+
|
|
253
|
+
1. Ensure all tests pass: `npm test`
|
|
254
|
+
2. Ensure no linting errors: `npm run lint`
|
|
255
|
+
3. Update documentation if needed
|
|
256
|
+
4. Add entries to CHANGELOG.md
|
|
257
|
+
5. Create a pull request with a clear description
|
|
258
|
+
|
|
259
|
+
### Commit Messages
|
|
260
|
+
|
|
261
|
+
Use clear, descriptive commit messages:
|
|
262
|
+
|
|
263
|
+
```
|
|
264
|
+
Add new tool for X functionality
|
|
265
|
+
|
|
266
|
+
- Implement X feature
|
|
267
|
+
- Add tests for X
|
|
268
|
+
- Update documentation
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Review Process
|
|
272
|
+
|
|
273
|
+
- All changes require review before merging
|
|
274
|
+
- Address review feedback promptly
|
|
275
|
+
- Keep discussions constructive
|
|
276
|
+
|
|
277
|
+
## Questions?
|
|
278
|
+
|
|
279
|
+
If you have questions, please:
|
|
280
|
+
|
|
281
|
+
1. Check existing issues
|
|
282
|
+
2. Read the documentation
|
|
283
|
+
3. Open a new issue with your question
|
|
284
|
+
|
|
285
|
+
Thank you for contributing!
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Sidney Bissoli
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|