flin-linkedin-posts-mcp 0.1.1__tar.gz
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.
- flin_linkedin_posts_mcp-0.1.1/.env.example +6 -0
- flin_linkedin_posts_mcp-0.1.1/.github/workflows/ci.yml +51 -0
- flin_linkedin_posts_mcp-0.1.1/.github/workflows/release.yml +74 -0
- flin_linkedin_posts_mcp-0.1.1/.gitignore +12 -0
- flin_linkedin_posts_mcp-0.1.1/LICENSE +21 -0
- flin_linkedin_posts_mcp-0.1.1/PKG-INFO +127 -0
- flin_linkedin_posts_mcp-0.1.1/README.md +106 -0
- flin_linkedin_posts_mcp-0.1.1/pyproject.toml +51 -0
- flin_linkedin_posts_mcp-0.1.1/src/flin_linkedin_posts_mcp/__init__.py +9 -0
- flin_linkedin_posts_mcp-0.1.1/src/flin_linkedin_posts_mcp/config.py +29 -0
- flin_linkedin_posts_mcp-0.1.1/src/flin_linkedin_posts_mcp/dispatcher.py +48 -0
- flin_linkedin_posts_mcp-0.1.1/src/flin_linkedin_posts_mcp/errors.py +39 -0
- flin_linkedin_posts_mcp-0.1.1/src/flin_linkedin_posts_mcp/guards.py +14 -0
- flin_linkedin_posts_mcp-0.1.1/src/flin_linkedin_posts_mcp/linkedin_client.py +180 -0
- flin_linkedin_posts_mcp-0.1.1/src/flin_linkedin_posts_mcp/response.py +51 -0
- flin_linkedin_posts_mcp-0.1.1/src/flin_linkedin_posts_mcp/server.py +111 -0
- flin_linkedin_posts_mcp-0.1.1/src/flin_linkedin_posts_mcp/tool_registry.py +69 -0
- flin_linkedin_posts_mcp-0.1.1/src/flin_linkedin_posts_mcp/tools/__init__.py +1 -0
- flin_linkedin_posts_mcp-0.1.1/src/flin_linkedin_posts_mcp/tools/common.py +35 -0
- flin_linkedin_posts_mcp-0.1.1/src/flin_linkedin_posts_mcp/tools/member_posts.py +259 -0
- flin_linkedin_posts_mcp-0.1.1/tests/conftest.py +10 -0
- flin_linkedin_posts_mcp-0.1.1/tests/test_config.py +28 -0
- flin_linkedin_posts_mcp-0.1.1/tests/test_guards.py +17 -0
- flin_linkedin_posts_mcp-0.1.1/tests/test_linkedin_client.py +101 -0
- flin_linkedin_posts_mcp-0.1.1/tests/test_member_posts.py +97 -0
- flin_linkedin_posts_mcp-0.1.1/tests/test_response.py +20 -0
- flin_linkedin_posts_mcp-0.1.1/tests/test_server.py +71 -0
- flin_linkedin_posts_mcp-0.1.1/tests/test_server_import.py +7 -0
- flin_linkedin_posts_mcp-0.1.1/tests/test_tool_registry.py +14 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
env:
|
|
11
|
+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
|
12
|
+
PYTHONUNBUFFERED: "1"
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
test:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
strategy:
|
|
18
|
+
fail-fast: false
|
|
19
|
+
matrix:
|
|
20
|
+
python-version: ["3.11", "3.12"]
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- name: Checkout
|
|
24
|
+
uses: actions/checkout@v6
|
|
25
|
+
|
|
26
|
+
- name: Set up Python
|
|
27
|
+
uses: actions/setup-python@v6
|
|
28
|
+
with:
|
|
29
|
+
python-version: ${{ matrix.python-version }}
|
|
30
|
+
cache: pip
|
|
31
|
+
cache-dependency-path: pyproject.toml
|
|
32
|
+
|
|
33
|
+
- name: Install package with dev extras
|
|
34
|
+
run: |
|
|
35
|
+
python -m pip install --upgrade pip
|
|
36
|
+
python -m pip install -e ".[dev]" build twine
|
|
37
|
+
|
|
38
|
+
- name: Lint
|
|
39
|
+
run: ruff check .
|
|
40
|
+
|
|
41
|
+
- name: Type check
|
|
42
|
+
run: mypy src
|
|
43
|
+
|
|
44
|
+
- name: Test
|
|
45
|
+
run: pytest -q
|
|
46
|
+
|
|
47
|
+
- name: Build package
|
|
48
|
+
run: python -m build
|
|
49
|
+
|
|
50
|
+
- name: Verify distributions
|
|
51
|
+
run: twine check dist/*
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
id-token: write
|
|
11
|
+
|
|
12
|
+
env:
|
|
13
|
+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
|
14
|
+
PYTHONUNBUFFERED: "1"
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
release:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
environment: pypi
|
|
20
|
+
|
|
21
|
+
steps:
|
|
22
|
+
- name: Checkout
|
|
23
|
+
uses: actions/checkout@v6
|
|
24
|
+
|
|
25
|
+
- name: Set up Python
|
|
26
|
+
uses: actions/setup-python@v6
|
|
27
|
+
with:
|
|
28
|
+
python-version: "3.12"
|
|
29
|
+
cache: pip
|
|
30
|
+
cache-dependency-path: pyproject.toml
|
|
31
|
+
|
|
32
|
+
- name: Install dependencies
|
|
33
|
+
run: |
|
|
34
|
+
python -m pip install --upgrade pip
|
|
35
|
+
python -m pip install -e ".[dev]" build twine
|
|
36
|
+
|
|
37
|
+
- name: Verify tag matches package version
|
|
38
|
+
run: |
|
|
39
|
+
TAG_VERSION="${GITHUB_REF_NAME#v}"
|
|
40
|
+
PROJECT_VERSION="$(python - <<'PY'
|
|
41
|
+
import tomllib
|
|
42
|
+
from pathlib import Path
|
|
43
|
+
pyproject = Path("pyproject.toml")
|
|
44
|
+
data = tomllib.loads(pyproject.read_text(encoding="utf-8"))
|
|
45
|
+
print(data["project"]["version"])
|
|
46
|
+
PY
|
|
47
|
+
)"
|
|
48
|
+
if [ "$TAG_VERSION" != "$PROJECT_VERSION" ]; then
|
|
49
|
+
echo "Tag version ($TAG_VERSION) does not match pyproject.toml version ($PROJECT_VERSION)."
|
|
50
|
+
exit 1
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
- name: Verify quality gates
|
|
54
|
+
run: |
|
|
55
|
+
ruff check .
|
|
56
|
+
mypy src
|
|
57
|
+
pytest -q
|
|
58
|
+
|
|
59
|
+
- name: Build distributions
|
|
60
|
+
run: python -m build
|
|
61
|
+
|
|
62
|
+
- name: Verify distributions
|
|
63
|
+
run: twine check dist/*
|
|
64
|
+
|
|
65
|
+
- name: Publish to PyPI (Trusted Publishing)
|
|
66
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
67
|
+
|
|
68
|
+
- name: Create GitHub Release with artifacts
|
|
69
|
+
env:
|
|
70
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
71
|
+
run: |
|
|
72
|
+
gh release create "${GITHUB_REF_NAME}" dist/* \
|
|
73
|
+
--title "${GITHUB_REF_NAME}" \
|
|
74
|
+
--generate-notes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 flin.agency
|
|
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.
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: flin-linkedin-posts-mcp
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Read-only MCP server for LinkedIn member posts analysis
|
|
5
|
+
Project-URL: Homepage, https://github.com/flin-agency/flin-linkedin-posts-mcp
|
|
6
|
+
Project-URL: Repository, https://github.com/flin-agency/flin-linkedin-posts-mcp
|
|
7
|
+
Project-URL: Issues, https://github.com/flin-agency/flin-linkedin-posts-mcp/issues
|
|
8
|
+
Author: flin.agency
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: linkedin,linkedin-posts,mcp,model-context-protocol
|
|
12
|
+
Requires-Python: >=3.11
|
|
13
|
+
Requires-Dist: httpx>=0.28.1
|
|
14
|
+
Requires-Dist: mcp>=1.0.0
|
|
15
|
+
Provides-Extra: dev
|
|
16
|
+
Requires-Dist: mypy>=1.11; extra == 'dev'
|
|
17
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
18
|
+
Requires-Dist: respx>=0.21; extra == 'dev'
|
|
19
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# flin-linkedin-posts-mcp
|
|
23
|
+
|
|
24
|
+
`flin-linkedin-posts-mcp` ist ein read-only MCP-Server für persönliche LinkedIn-Posts eines Nutzers.
|
|
25
|
+
|
|
26
|
+
## Features
|
|
27
|
+
|
|
28
|
+
- Aktuelles LinkedIn-Mitglied über `https://api.linkedin.com/v2/userinfo` aus dem Access-Token auflösen
|
|
29
|
+
- Eigene Posts oder Posts eines bestimmten Mitglieds laden
|
|
30
|
+
- Einzelne Posts normalisiert abrufen
|
|
31
|
+
- Posts automatisch analysieren: Textlänge, Hashtags, Erwähnungen und Top-Begriffe
|
|
32
|
+
|
|
33
|
+
## Verfügbare MCP-Tools
|
|
34
|
+
|
|
35
|
+
1. `get_member_profile`
|
|
36
|
+
2. `list_member_posts`
|
|
37
|
+
3. `get_post`
|
|
38
|
+
4. `analyze_member_posts`
|
|
39
|
+
|
|
40
|
+
## Benötigte Umgebungsvariablen
|
|
41
|
+
|
|
42
|
+
- `LINKEDIN_ACCESS_TOKEN`
|
|
43
|
+
- `LINKEDIN_API_VERSION` (Default: `202603`)
|
|
44
|
+
- `LINKEDIN_RESTLI_PROTOCOL_VERSION` (Default: `2.0.0`)
|
|
45
|
+
- `LINKEDIN_TIMEOUT_SECONDS` (Default: `30`)
|
|
46
|
+
- `LINKEDIN_MAX_RETRIES` (Default: `3`)
|
|
47
|
+
|
|
48
|
+
## Installation
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
python -m pip install -e '.[dev]'
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Beispiel Claude Desktop Konfiguration
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"mcpServers": {
|
|
59
|
+
"flin-linkedin-posts-mcp": {
|
|
60
|
+
"command": "uvx",
|
|
61
|
+
"args": ["--refresh", "flin-linkedin-posts-mcp"],
|
|
62
|
+
"env": {
|
|
63
|
+
"LINKEDIN_ACCESS_TOKEN": "AQX...",
|
|
64
|
+
"LINKEDIN_API_VERSION": "202603",
|
|
65
|
+
"LINKEDIN_RESTLI_PROTOCOL_VERSION": "2.0.0"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Veröffentlichung auf PyPI (direkt über GitHub)
|
|
73
|
+
|
|
74
|
+
1. PyPI Trusted Publishing für dieses Repo einrichten:
|
|
75
|
+
- PyPI Projekt: `flin-linkedin-posts-mcp`
|
|
76
|
+
- Publisher: GitHub Actions
|
|
77
|
+
- Repository: `flin-agency/flin-linkedin-posts-mcp`
|
|
78
|
+
- Workflow: `.github/workflows/release.yml`
|
|
79
|
+
- Environment: `pypi`
|
|
80
|
+
2. Version in `pyproject.toml` erhöhen.
|
|
81
|
+
3. Tag im Format `vX.Y.Z` erstellen und pushen:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
git tag v0.1.1
|
|
85
|
+
git push origin v0.1.1
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
4. Der Release-Workflow prüft automatisch:
|
|
89
|
+
- Tag-Version == `project.version` in `pyproject.toml`
|
|
90
|
+
- `ruff`, `mypy`, `pytest`
|
|
91
|
+
- Build + `twine check`
|
|
92
|
+
5. Danach publiziert GitHub Actions direkt nach PyPI und erstellt ein GitHub Release.
|
|
93
|
+
|
|
94
|
+
## Claude-Test mit veröffentlichtem Paket (`uvx`)
|
|
95
|
+
|
|
96
|
+
Nach erfolgreichem PyPI-Release in Claude Desktop:
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"mcpServers": {
|
|
101
|
+
"flin-linkedin-posts-mcp": {
|
|
102
|
+
"command": "uvx",
|
|
103
|
+
"args": ["--refresh", "flin-linkedin-posts-mcp"],
|
|
104
|
+
"env": {
|
|
105
|
+
"LINKEDIN_ACCESS_TOKEN": "AQX...",
|
|
106
|
+
"LINKEDIN_API_VERSION": "202603",
|
|
107
|
+
"LINKEDIN_RESTLI_PROTOCOL_VERSION": "2.0.0"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Claude Desktop danach komplett neu starten.
|
|
115
|
+
|
|
116
|
+
## Entwicklung
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
pytest -q
|
|
120
|
+
ruff check .
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Hinweise
|
|
124
|
+
|
|
125
|
+
- Wenn `author_urn` fehlt, versucht der Server den aktuell authentifizierten Nutzer über `https://api.linkedin.com/v2/userinfo` aufzulösen.
|
|
126
|
+
- Dafür braucht das Token in der Praxis meist passende OpenID-/Userinfo-Berechtigungen.
|
|
127
|
+
- Die Post-Analyse ist heuristisch und basiert auf Text, Hashtags und Erwähnungen der geladenen Posts.
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# flin-linkedin-posts-mcp
|
|
2
|
+
|
|
3
|
+
`flin-linkedin-posts-mcp` ist ein read-only MCP-Server für persönliche LinkedIn-Posts eines Nutzers.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Aktuelles LinkedIn-Mitglied über `https://api.linkedin.com/v2/userinfo` aus dem Access-Token auflösen
|
|
8
|
+
- Eigene Posts oder Posts eines bestimmten Mitglieds laden
|
|
9
|
+
- Einzelne Posts normalisiert abrufen
|
|
10
|
+
- Posts automatisch analysieren: Textlänge, Hashtags, Erwähnungen und Top-Begriffe
|
|
11
|
+
|
|
12
|
+
## Verfügbare MCP-Tools
|
|
13
|
+
|
|
14
|
+
1. `get_member_profile`
|
|
15
|
+
2. `list_member_posts`
|
|
16
|
+
3. `get_post`
|
|
17
|
+
4. `analyze_member_posts`
|
|
18
|
+
|
|
19
|
+
## Benötigte Umgebungsvariablen
|
|
20
|
+
|
|
21
|
+
- `LINKEDIN_ACCESS_TOKEN`
|
|
22
|
+
- `LINKEDIN_API_VERSION` (Default: `202603`)
|
|
23
|
+
- `LINKEDIN_RESTLI_PROTOCOL_VERSION` (Default: `2.0.0`)
|
|
24
|
+
- `LINKEDIN_TIMEOUT_SECONDS` (Default: `30`)
|
|
25
|
+
- `LINKEDIN_MAX_RETRIES` (Default: `3`)
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
python -m pip install -e '.[dev]'
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Beispiel Claude Desktop Konfiguration
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"mcpServers": {
|
|
38
|
+
"flin-linkedin-posts-mcp": {
|
|
39
|
+
"command": "uvx",
|
|
40
|
+
"args": ["--refresh", "flin-linkedin-posts-mcp"],
|
|
41
|
+
"env": {
|
|
42
|
+
"LINKEDIN_ACCESS_TOKEN": "AQX...",
|
|
43
|
+
"LINKEDIN_API_VERSION": "202603",
|
|
44
|
+
"LINKEDIN_RESTLI_PROTOCOL_VERSION": "2.0.0"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Veröffentlichung auf PyPI (direkt über GitHub)
|
|
52
|
+
|
|
53
|
+
1. PyPI Trusted Publishing für dieses Repo einrichten:
|
|
54
|
+
- PyPI Projekt: `flin-linkedin-posts-mcp`
|
|
55
|
+
- Publisher: GitHub Actions
|
|
56
|
+
- Repository: `flin-agency/flin-linkedin-posts-mcp`
|
|
57
|
+
- Workflow: `.github/workflows/release.yml`
|
|
58
|
+
- Environment: `pypi`
|
|
59
|
+
2. Version in `pyproject.toml` erhöhen.
|
|
60
|
+
3. Tag im Format `vX.Y.Z` erstellen und pushen:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
git tag v0.1.1
|
|
64
|
+
git push origin v0.1.1
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
4. Der Release-Workflow prüft automatisch:
|
|
68
|
+
- Tag-Version == `project.version` in `pyproject.toml`
|
|
69
|
+
- `ruff`, `mypy`, `pytest`
|
|
70
|
+
- Build + `twine check`
|
|
71
|
+
5. Danach publiziert GitHub Actions direkt nach PyPI und erstellt ein GitHub Release.
|
|
72
|
+
|
|
73
|
+
## Claude-Test mit veröffentlichtem Paket (`uvx`)
|
|
74
|
+
|
|
75
|
+
Nach erfolgreichem PyPI-Release in Claude Desktop:
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"mcpServers": {
|
|
80
|
+
"flin-linkedin-posts-mcp": {
|
|
81
|
+
"command": "uvx",
|
|
82
|
+
"args": ["--refresh", "flin-linkedin-posts-mcp"],
|
|
83
|
+
"env": {
|
|
84
|
+
"LINKEDIN_ACCESS_TOKEN": "AQX...",
|
|
85
|
+
"LINKEDIN_API_VERSION": "202603",
|
|
86
|
+
"LINKEDIN_RESTLI_PROTOCOL_VERSION": "2.0.0"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Claude Desktop danach komplett neu starten.
|
|
94
|
+
|
|
95
|
+
## Entwicklung
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
pytest -q
|
|
99
|
+
ruff check .
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Hinweise
|
|
103
|
+
|
|
104
|
+
- Wenn `author_urn` fehlt, versucht der Server den aktuell authentifizierten Nutzer über `https://api.linkedin.com/v2/userinfo` aufzulösen.
|
|
105
|
+
- Dafür braucht das Token in der Praxis meist passende OpenID-/Userinfo-Berechtigungen.
|
|
106
|
+
- Die Post-Analyse ist heuristisch und basiert auf Text, Hashtags und Erwähnungen der geladenen Posts.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.24"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "flin-linkedin-posts-mcp"
|
|
7
|
+
version = "0.1.1"
|
|
8
|
+
description = "Read-only MCP server for LinkedIn member posts analysis"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "flin.agency" }
|
|
14
|
+
]
|
|
15
|
+
keywords = ["mcp", "linkedin-posts", "linkedin", "model-context-protocol"]
|
|
16
|
+
dependencies = [
|
|
17
|
+
"httpx>=0.28.1",
|
|
18
|
+
"mcp>=1.0.0",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[project.optional-dependencies]
|
|
22
|
+
dev = [
|
|
23
|
+
"pytest>=8.0",
|
|
24
|
+
"respx>=0.21",
|
|
25
|
+
"ruff>=0.6",
|
|
26
|
+
"mypy>=1.11",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.scripts]
|
|
30
|
+
flin-linkedin-posts-mcp = "flin_linkedin_posts_mcp.server:main"
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
Homepage = "https://github.com/flin-agency/flin-linkedin-posts-mcp"
|
|
34
|
+
Repository = "https://github.com/flin-agency/flin-linkedin-posts-mcp"
|
|
35
|
+
Issues = "https://github.com/flin-agency/flin-linkedin-posts-mcp/issues"
|
|
36
|
+
|
|
37
|
+
[tool.hatch.build.targets.wheel]
|
|
38
|
+
packages = ["src/flin_linkedin_posts_mcp"]
|
|
39
|
+
|
|
40
|
+
[tool.pytest.ini_options]
|
|
41
|
+
testpaths = ["tests"]
|
|
42
|
+
pythonpath = ["src"]
|
|
43
|
+
|
|
44
|
+
[tool.ruff]
|
|
45
|
+
target-version = "py311"
|
|
46
|
+
line-length = 100
|
|
47
|
+
|
|
48
|
+
[tool.mypy]
|
|
49
|
+
python_version = "3.11"
|
|
50
|
+
warn_unused_configs = true
|
|
51
|
+
ignore_missing_imports = true
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
import os
|
|
5
|
+
from typing import Mapping
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass(frozen=True, slots=True)
|
|
9
|
+
class LinkedInPostsSettings:
|
|
10
|
+
access_token: str
|
|
11
|
+
api_version: str
|
|
12
|
+
restli_protocol_version: str
|
|
13
|
+
timeout_seconds: float
|
|
14
|
+
max_retries: int
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def load_config(env: Mapping[str, str] | None = None) -> LinkedInPostsSettings:
|
|
18
|
+
source = os.environ if env is None else env
|
|
19
|
+
access_token = source.get("LINKEDIN_ACCESS_TOKEN")
|
|
20
|
+
if not access_token:
|
|
21
|
+
raise ValueError("LINKEDIN_ACCESS_TOKEN is required")
|
|
22
|
+
|
|
23
|
+
return LinkedInPostsSettings(
|
|
24
|
+
access_token=access_token,
|
|
25
|
+
api_version=source.get("LINKEDIN_API_VERSION", "202603"),
|
|
26
|
+
restli_protocol_version=source.get("LINKEDIN_RESTLI_PROTOCOL_VERSION", "2.0.0"),
|
|
27
|
+
timeout_seconds=float(source.get("LINKEDIN_TIMEOUT_SECONDS", "30")),
|
|
28
|
+
max_retries=int(source.get("LINKEDIN_MAX_RETRIES", "3")),
|
|
29
|
+
)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any, Callable
|
|
4
|
+
|
|
5
|
+
from .config import LinkedInPostsSettings
|
|
6
|
+
from .guards import assert_read_only_tool
|
|
7
|
+
from .linkedin_client import LinkedInClient
|
|
8
|
+
from .tools.member_posts import analyze_member_posts, get_member_profile, get_post, list_member_posts
|
|
9
|
+
|
|
10
|
+
ToolHandler = Callable[[LinkedInClient, LinkedInPostsSettings, dict[str, Any]], dict[str, Any]]
|
|
11
|
+
|
|
12
|
+
TOOL_HANDLERS: dict[str, ToolHandler] = {
|
|
13
|
+
"get_member_profile": lambda client, settings, arguments: get_member_profile(
|
|
14
|
+
client=client,
|
|
15
|
+
settings=settings,
|
|
16
|
+
arguments=arguments,
|
|
17
|
+
),
|
|
18
|
+
"list_member_posts": lambda client, settings, arguments: list_member_posts(
|
|
19
|
+
client=client,
|
|
20
|
+
settings=settings,
|
|
21
|
+
arguments=arguments,
|
|
22
|
+
),
|
|
23
|
+
"get_post": lambda client, settings, arguments: get_post(
|
|
24
|
+
client=client,
|
|
25
|
+
settings=settings,
|
|
26
|
+
arguments=arguments,
|
|
27
|
+
),
|
|
28
|
+
"analyze_member_posts": lambda client, settings, arguments: analyze_member_posts(
|
|
29
|
+
client=client,
|
|
30
|
+
settings=settings,
|
|
31
|
+
arguments=arguments,
|
|
32
|
+
),
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def dispatch_tool(
|
|
37
|
+
name: str,
|
|
38
|
+
arguments: dict[str, Any],
|
|
39
|
+
*,
|
|
40
|
+
settings: LinkedInPostsSettings,
|
|
41
|
+
client: LinkedInClient,
|
|
42
|
+
) -> dict[str, Any]:
|
|
43
|
+
assert_read_only_tool(name)
|
|
44
|
+
try:
|
|
45
|
+
handler = TOOL_HANDLERS[name]
|
|
46
|
+
except KeyError as exc:
|
|
47
|
+
raise KeyError(f"Unknown tool: {name}") from exc
|
|
48
|
+
return handler(client, settings, arguments)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class LinkedInPostsError(Exception):
|
|
5
|
+
error_code = "linkedin_api_error"
|
|
6
|
+
|
|
7
|
+
def __init__(
|
|
8
|
+
self,
|
|
9
|
+
message: str,
|
|
10
|
+
*,
|
|
11
|
+
status_code: int | None = None,
|
|
12
|
+
request_id: str | None = None,
|
|
13
|
+
details: dict | None = None,
|
|
14
|
+
) -> None:
|
|
15
|
+
super().__init__(message)
|
|
16
|
+
self.message = message
|
|
17
|
+
self.status_code = status_code
|
|
18
|
+
self.request_id = request_id
|
|
19
|
+
self.details = details or {}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class LinkedInAuthError(LinkedInPostsError):
|
|
23
|
+
error_code = "auth_error"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class LinkedInPermissionError(LinkedInPostsError):
|
|
27
|
+
error_code = "permission_error"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class LinkedInRateLimitError(LinkedInPostsError):
|
|
31
|
+
error_code = "rate_limit_error"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class LinkedInValidationError(LinkedInPostsError):
|
|
35
|
+
error_code = "validation_error"
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class LinkedInAPIError(LinkedInPostsError):
|
|
39
|
+
error_code = "linkedin_api_error"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
READ_ONLY_TOOL_NAMES = {
|
|
5
|
+
"get_member_profile",
|
|
6
|
+
"list_member_posts",
|
|
7
|
+
"get_post",
|
|
8
|
+
"analyze_member_posts",
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def assert_read_only_tool(name: str) -> None:
|
|
13
|
+
if name not in READ_ONLY_TOOL_NAMES:
|
|
14
|
+
raise PermissionError("Tool is not allowed in strict read-only mode")
|