Skip to content

Commit ba5a49e

Browse files
feat: Use llm.txt for doc reference. rewrite this pr to include searc… (#21)
* feat: Use llm.txt for doc reference. rewrite this pr to include search doc based on frequency and relevance & fetch doc from uri * fix: Remove unrelated files * fix: revert code change in github workflow * fix: readme naming fix * fix: remove comment * fix: refactor some code, optimize some logic * fix:revert github workflow
1 parent f88c490 commit ba5a49e

File tree

15 files changed

+838
-604
lines changed

15 files changed

+838
-604
lines changed

.github/workflows/pypi-publish-on-release.yml

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -22,37 +22,37 @@ jobs:
2222
runs-on: ubuntu-latest
2323

2424
steps:
25-
- uses: actions/checkout@v4
26-
with:
27-
persist-credentials: false
25+
- uses: actions/checkout@v4
26+
with:
27+
persist-credentials: false
2828

29-
- name: Set up Python
30-
uses: actions/setup-python@v5
31-
with:
32-
python-version: '3.10'
29+
- name: Set up Python
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: '3.10'
3333

34-
- name: Install dependencies
35-
run: |
36-
python -m pip install --upgrade pip
37-
pip install hatch twine
38-
- name: Validate version
39-
run: |
40-
version=$(hatch version)
41-
if [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
42-
echo "Valid version format"
43-
exit 0
44-
else
45-
echo "Invalid version format"
46-
exit 1
47-
fi
48-
- name: Build
49-
run: |
50-
hatch build
51-
- name: Store the distribution packages
52-
uses: actions/upload-artifact@v4
53-
with:
54-
name: python-package-distributions
55-
path: dist/
34+
- name: Install dependencies
35+
run: |
36+
python -m pip install --upgrade pip
37+
pip install hatch twine
38+
- name: Validate version
39+
run: |
40+
version=$(hatch version)
41+
if [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
42+
echo "Valid version format"
43+
exit 0
44+
else
45+
echo "Invalid version format"
46+
exit 1
47+
fi
48+
- name: Build
49+
run: |
50+
hatch build
51+
- name: Store the distribution packages
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: python-package-distributions
55+
path: dist/
5656

5757
deploy:
5858
name: Upload release to PyPI
@@ -70,10 +70,10 @@ jobs:
7070
id-token: write
7171

7272
steps:
73-
- name: Download all the dists
74-
uses: actions/download-artifact@v4
75-
with:
76-
name: python-package-distributions
77-
path: dist/
78-
- name: Publish distribution 📦 to PyPI
79-
uses: pypa/gh-action-pypi-publish@release/v1
73+
- name: Download all the dists
74+
uses: actions/download-artifact@v4
75+
with:
76+
name: python-package-distributions
77+
path: dist/
78+
- name: Publish distribution 📦 to PyPI
79+
uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ __pycache__*
1010
.vscode
1111
dist
1212
venv/
13-
*.egg-info
13+
*.egg-info

README.md

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,15 @@
3232
</p>
3333
</div>
3434

35-
This MCP server provides documentation about Strands Agents to your GenAI tools, so you can use your favorite AI coding assistant to vibe-code Strands Agents.
35+
This MCP server provides curated documentation access to your GenAI tools via llms.txt files, enabling AI coding assistants to search and retrieve relevant documentation with intelligent ranking.
36+
37+
## Features
38+
39+
- **Smart Document Search**: TF-IDF based search with Markdown-aware scoring that prioritizes titles, headers, and code blocks
40+
- **Curated Content**: Indexes documentation from llms.txt files with clean, human-readable titles
41+
- **On-Demand Fetching**: Lazy-loads full document content only when needed for optimal performance
42+
- **Snippet Generation**: Provides contextual snippets with relevance scoring for quick overview
43+
- **Real URL Support**: Works with actual HTTPS URLs while maintaining backward compatibility
3644

3745
## Prerequisites
3846

@@ -54,9 +62,17 @@ In `~/.aws/amazonq/mcp.json`:
5462
```json
5563
{
5664
"mcpServers": {
57-
"strands": {
65+
"strands-agents": {
5866
"command": "uvx",
59-
"args": ["strands-agents-mcp-server"]
67+
"args": ["strands-agents-mcp-server"],
68+
"env": {
69+
"FASTMCP_LOG_LEVEL": "INFO"
70+
},
71+
"disabled": false,
72+
"autoApprove": [
73+
"search_docs",
74+
"fetch_doc"
75+
]
6076
}
6177
}
6278
}
@@ -94,9 +110,17 @@ In `~/.cursor/mcp.json`:
94110
```json
95111
{
96112
"mcpServers": {
97-
"strands": {
113+
"strands-agents": {
98114
"command": "uvx",
99-
"args": ["strands-agents-mcp-server"]
115+
"args": ["strands-agents-mcp-server"],
116+
"env": {
117+
"FASTMCP_LOG_LEVEL": "INFO"
118+
},
119+
"disabled": false,
120+
"autoApprove": [
121+
"search_docs",
122+
"fetch_doc"
123+
]
100124
}
101125
}
102126
}
@@ -107,14 +131,42 @@ In `~/.cursor/mcp.json`:
107131
You can quickly test the MCP server using the MCP Inspector:
108132

109133
```bash
134+
# For published package
110135
npx @modelcontextprotocol/inspector uvx strands-agents-mcp-server
136+
137+
# For local development
138+
npx @modelcontextprotocol/inspector python -m strands_mcp_server
111139
```
112140

113141
Note: This requires [npx](https://docs.npmjs.com/cli/v11/commands/npx) to be installed on your system. It comes bundled with [Node.js](https://nodejs.org/).
114142

115143
The Inspector is also useful for troubleshooting MCP server issues as it provides detailed connection and protocol information. For an in-depth guide, have a look at the [MCP Inspector documentation](https://modelcontextprotocol.io/docs/tools/inspector).
116144

117-
## Server development
145+
## Getting Started
146+
147+
1. **Install prerequisites**:
148+
- Install [uv](https://github.com/astral-sh/uv) following the [official installation instructions](https://github.com/astral-sh/uv#installation)
149+
- Make sure you have [Node.js](https://nodejs.org/) installed for npx commands
150+
151+
2. **Configure your MCP client**:
152+
- Choose your preferred MCP client from the installation examples above
153+
- Add the Strands Agents MCP server configuration to your client
154+
155+
3. **Test the connection**:
156+
```bash
157+
# For published package
158+
npx @modelcontextprotocol/inspector uvx strands-agents-mcp-server
159+
160+
# For local development
161+
npx @modelcontextprotocol/inspector python -m strands_mcp_server
162+
```
163+
164+
4. **Start using the documentation tools**:
165+
- Use `search_docs` to find relevant documentation with intelligent ranking
166+
- Use `fetch_doc` to retrieve full content from specific URLs
167+
- The server automatically indexes curated content from llms.txt files
168+
169+
## Server Development
118170

119171
```bash
120172
git clone https://github.com/strands-agents/mcp-server.git

src/strands_mcp_server/__init__.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +0,0 @@
1-
from . import server
2-
3-
4-
def main():
5-
"""Strands Agents MCP Server"""
6-
server.main()
7-
8-
9-
if __name__ == "__main__":
10-
main()

src/strands_mcp_server/__main__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1-
from strands_mcp_server import main
1+
"""Entry point for running the Strands MCP Server as a module.
22
3-
main()
3+
Usage:
4+
python -m strands_mcp_server
5+
"""
6+
7+
from .server import main
8+
9+
if __name__ == "__main__":
10+
main()

src/strands_mcp_server/config.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from dataclasses import dataclass, field
2+
3+
4+
@dataclass
5+
class Config:
6+
"""Configuration settings for the MCP server.
7+
8+
Attributes:
9+
llm_texts_url: List of llms.txt URLs to index for documentation
10+
timeout: HTTP request timeout in seconds
11+
user_agent: User agent string for HTTP requests
12+
"""
13+
14+
llm_texts_url: list[str] = field(
15+
default_factory=lambda: ["https://strandsagents.com/latest/llms.txt"]
16+
) # Curated list of llms.txt files to index at startup
17+
timeout: float = 30.0 # HTTP request timeout in seconds
18+
user_agent: str = "strands-mcp-docs/1.0" # User agent for HTTP requests
19+
20+
21+
# Global configuration instance
22+
doc_config = Config()

0 commit comments

Comments
 (0)