cnks 0.1.1__py3-none-any.whl → 0.2.1__py3-none-any.whl

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.
@@ -1,841 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: cnks
3
- Version: 0.1.1
4
- Summary: CNKI Search tool with Chrome browser integration
5
- Author-email: bai-z-l <b@iziliang.com>
6
- Requires-Python: >=3.13
7
- Requires-Dist: mcp[cli]>=1.6.0
8
- Requires-Dist: playwright>=1.51.0
9
- Requires-Dist: pydantic>=2.11.3
10
- Description-Content-Type: text/markdown
11
-
12
- # MCP Python SDK
13
-
14
- <div align="center">
15
-
16
- <strong>Python implementation of the Model Context Protocol (MCP)</strong>
17
-
18
- [![PyPI][pypi-badge]][pypi-url]
19
- [![MIT licensed][mit-badge]][mit-url]
20
- [![Python Version][python-badge]][python-url]
21
- [![Documentation][docs-badge]][docs-url]
22
- [![Specification][spec-badge]][spec-url]
23
- [![GitHub Discussions][discussions-badge]][discussions-url]
24
-
25
- </div>
26
-
27
- <!-- omit in toc -->
28
- ## Table of Contents
29
-
30
- - [MCP Python SDK](#mcp-python-sdk)
31
- - [Overview](#overview)
32
- - [Installation](#installation)
33
- - [Adding MCP to your python project](#adding-mcp-to-your-python-project)
34
- - [Running the standalone MCP development tools](#running-the-standalone-mcp-development-tools)
35
- - [Quickstart](#quickstart)
36
- - [What is MCP?](#what-is-mcp)
37
- - [Core Concepts](#core-concepts)
38
- - [Server](#server)
39
- - [Resources](#resources)
40
- - [Tools](#tools)
41
- - [Prompts](#prompts)
42
- - [Images](#images)
43
- - [Context](#context)
44
- - [Running Your Server](#running-your-server)
45
- - [Development Mode](#development-mode)
46
- - [Claude Desktop Integration](#claude-desktop-integration)
47
- - [Direct Execution](#direct-execution)
48
- - [Mounting to an Existing ASGI Server](#mounting-to-an-existing-asgi-server)
49
- - [Examples](#examples)
50
- - [Echo Server](#echo-server)
51
- - [SQLite Explorer](#sqlite-explorer)
52
- - [Advanced Usage](#advanced-usage)
53
- - [Low-Level Server](#low-level-server)
54
- - [Writing MCP Clients](#writing-mcp-clients)
55
- - [MCP Primitives](#mcp-primitives)
56
- - [Server Capabilities](#server-capabilities)
57
- - [Documentation](#documentation)
58
- - [Contributing](#contributing)
59
- - [License](#license)
60
-
61
- [pypi-badge]: https://img.shields.io/pypi/v/mcp.svg
62
- [pypi-url]: https://pypi.org/project/mcp/
63
- [mit-badge]: https://img.shields.io/pypi/l/mcp.svg
64
- [mit-url]: https://github.com/modelcontextprotocol/python-sdk/blob/main/LICENSE
65
- [python-badge]: https://img.shields.io/pypi/pyversions/mcp.svg
66
- [python-url]: https://www.python.org/downloads/
67
- [docs-badge]: https://img.shields.io/badge/docs-modelcontextprotocol.io-blue.svg
68
- [docs-url]: https://modelcontextprotocol.io
69
- [spec-badge]: https://img.shields.io/badge/spec-spec.modelcontextprotocol.io-blue.svg
70
- [spec-url]: https://spec.modelcontextprotocol.io
71
- [discussions-badge]: https://img.shields.io/github/discussions/modelcontextprotocol/python-sdk
72
- [discussions-url]: https://github.com/modelcontextprotocol/python-sdk/discussions
73
-
74
- ## Overview
75
-
76
- The Model Context Protocol allows applications to provide context for LLMs in a standardized way, separating the concerns of providing context from the actual LLM interaction. This Python SDK implements the full MCP specification, making it easy to:
77
-
78
- - Build MCP clients that can connect to any MCP server
79
- - Create MCP servers that expose resources, prompts and tools
80
- - Use standard transports like stdio and SSE
81
- - Handle all MCP protocol messages and lifecycle events
82
-
83
- ## Installation
84
-
85
- ### Adding MCP to your python project
86
-
87
- We recommend using [uv](https://docs.astral.sh/uv/) to manage your Python projects.
88
-
89
- If you haven't created a uv-managed project yet, create one:
90
-
91
- ```bash
92
- uv init mcp-server-demo
93
- cd mcp-server-demo
94
- ```
95
-
96
- Then add MCP to your project dependencies:
97
-
98
- ```bash
99
- uv add "mcp[cli]"
100
- ```
101
-
102
- Alternatively, for projects using pip for dependencies:
103
- ```bash
104
- pip install "mcp[cli]"
105
- ```
106
-
107
- ### Running the standalone MCP development tools
108
-
109
- To run the mcp command with uv:
110
-
111
- ```bash
112
- uv run mcp
113
- ```
114
-
115
- ## Quickstart
116
-
117
- Let's create a simple MCP server that exposes a calculator tool and some data:
118
-
119
- ```python
120
- # server.py
121
- from mcp.server.fastmcp import FastMCP
122
-
123
- # Create an MCP server
124
- mcp = FastMCP("Demo")
125
-
126
-
127
- # Add an addition tool
128
- @mcp.tool()
129
- def add(a: int, b: int) -> int:
130
- """Add two numbers"""
131
- return a + b
132
-
133
-
134
- # Add a dynamic greeting resource
135
- @mcp.resource("greeting://{name}")
136
- def get_greeting(name: str) -> str:
137
- """Get a personalized greeting"""
138
- return f"Hello, {name}!"
139
- ```
140
-
141
- You can install this server in [Claude Desktop](https://claude.ai/download) and interact with it right away by running:
142
- ```bash
143
- mcp install server.py
144
- ```
145
-
146
- Alternatively, you can test it with the MCP Inspector:
147
- ```bash
148
- mcp dev server.py
149
- ```
150
-
151
- ## What is MCP?
152
-
153
- The [Model Context Protocol (MCP)](https://modelcontextprotocol.io) lets you build servers that expose data and functionality to LLM applications in a secure, standardized way. Think of it like a web API, but specifically designed for LLM interactions. MCP servers can:
154
-
155
- - Expose data through **Resources** (think of these sort of like GET endpoints; they are used to load information into the LLM's context)
156
- - Provide functionality through **Tools** (sort of like POST endpoints; they are used to execute code or otherwise produce a side effect)
157
- - Define interaction patterns through **Prompts** (reusable templates for LLM interactions)
158
- - And more!
159
-
160
- ## Core Concepts
161
-
162
- ### Server
163
-
164
- The FastMCP server is your core interface to the MCP protocol. It handles connection management, protocol compliance, and message routing:
165
-
166
- ```python
167
- # Add lifespan support for startup/shutdown with strong typing
168
- from contextlib import asynccontextmanager
169
- from collections.abc import AsyncIterator
170
- from dataclasses import dataclass
171
-
172
- from fake_database import Database # Replace with your actual DB type
173
-
174
- from mcp.server.fastmcp import Context, FastMCP
175
-
176
- # Create a named server
177
- mcp = FastMCP("My App")
178
-
179
- # Specify dependencies for deployment and development
180
- mcp = FastMCP("My App", dependencies=["pandas", "numpy"])
181
-
182
-
183
- @dataclass
184
- class AppContext:
185
- db: Database
186
-
187
-
188
- @asynccontextmanager
189
- async def app_lifespan(server: FastMCP) -> AsyncIterator[AppContext]:
190
- """Manage application lifecycle with type-safe context"""
191
- # Initialize on startup
192
- db = await Database.connect()
193
- try:
194
- yield AppContext(db=db)
195
- finally:
196
- # Cleanup on shutdown
197
- await db.disconnect()
198
-
199
-
200
- # Pass lifespan to server
201
- mcp = FastMCP("My App", lifespan=app_lifespan)
202
-
203
-
204
- # Access type-safe lifespan context in tools
205
- @mcp.tool()
206
- def query_db(ctx: Context) -> str:
207
- """Tool that uses initialized resources"""
208
- db = ctx.request_context.lifespan_context.db
209
- return db.query()
210
- ```
211
-
212
- ### Resources
213
-
214
- Resources are how you expose data to LLMs. They're similar to GET endpoints in a REST API - they provide data but shouldn't perform significant computation or have side effects:
215
-
216
- ```python
217
- from mcp.server.fastmcp import FastMCP
218
-
219
- mcp = FastMCP("My App")
220
-
221
-
222
- @mcp.resource("config://app")
223
- def get_config() -> str:
224
- """Static configuration data"""
225
- return "App configuration here"
226
-
227
-
228
- @mcp.resource("users://{user_id}/profile")
229
- def get_user_profile(user_id: str) -> str:
230
- """Dynamic user data"""
231
- return f"Profile data for user {user_id}"
232
- ```
233
-
234
- ### Tools
235
-
236
- Tools let LLMs take actions through your server. Unlike resources, tools are expected to perform computation and have side effects:
237
-
238
- ```python
239
- import httpx
240
- from mcp.server.fastmcp import FastMCP
241
-
242
- mcp = FastMCP("My App")
243
-
244
-
245
- @mcp.tool()
246
- def calculate_bmi(weight_kg: float, height_m: float) -> float:
247
- """Calculate BMI given weight in kg and height in meters"""
248
- return weight_kg / (height_m**2)
249
-
250
-
251
- @mcp.tool()
252
- async def fetch_weather(city: str) -> str:
253
- """Fetch current weather for a city"""
254
- async with httpx.AsyncClient() as client:
255
- response = await client.get(f"https://api.weather.com/{city}")
256
- return response.text
257
- ```
258
-
259
- ### Prompts
260
-
261
- Prompts are reusable templates that help LLMs interact with your server effectively:
262
-
263
- ```python
264
- from mcp.server.fastmcp import FastMCP
265
- from mcp.server.fastmcp.prompts import base
266
-
267
- mcp = FastMCP("My App")
268
-
269
-
270
- @mcp.prompt()
271
- def review_code(code: str) -> str:
272
- return f"Please review this code:\n\n{code}"
273
-
274
-
275
- @mcp.prompt()
276
- def debug_error(error: str) -> list[base.Message]:
277
- return [
278
- base.UserMessage("I'm seeing this error:"),
279
- base.UserMessage(error),
280
- base.AssistantMessage("I'll help debug that. What have you tried so far?"),
281
- ]
282
- ```
283
-
284
- ### Images
285
-
286
- FastMCP provides an `Image` class that automatically handles image data:
287
-
288
- ```python
289
- from mcp.server.fastmcp import FastMCP, Image
290
- from PIL import Image as PILImage
291
-
292
- mcp = FastMCP("My App")
293
-
294
-
295
- @mcp.tool()
296
- def create_thumbnail(image_path: str) -> Image:
297
- """Create a thumbnail from an image"""
298
- img = PILImage.open(image_path)
299
- img.thumbnail((100, 100))
300
- return Image(data=img.tobytes(), format="png")
301
- ```
302
-
303
- ### Context
304
-
305
- The Context object gives your tools and resources access to MCP capabilities:
306
-
307
- ```python
308
- from mcp.server.fastmcp import FastMCP, Context
309
-
310
- mcp = FastMCP("My App")
311
-
312
-
313
- @mcp.tool()
314
- async def long_task(files: list[str], ctx: Context) -> str:
315
- """Process multiple files with progress tracking"""
316
- for i, file in enumerate(files):
317
- ctx.info(f"Processing {file}")
318
- await ctx.report_progress(i, len(files))
319
- data, mime_type = await ctx.read_resource(f"file://{file}")
320
- return "Processing complete"
321
- ```
322
-
323
- ## Running Your Server
324
-
325
- ### Development Mode
326
-
327
- The fastest way to test and debug your server is with the MCP Inspector:
328
-
329
- ```bash
330
- mcp dev server.py
331
-
332
- # Add dependencies
333
- mcp dev server.py --with pandas --with numpy
334
-
335
- # Mount local code
336
- mcp dev server.py --with-editable .
337
- ```
338
-
339
- ### Claude Desktop Integration
340
-
341
- Once your server is ready, install it in Claude Desktop:
342
-
343
- ```bash
344
- mcp install server.py
345
-
346
- # Custom name
347
- mcp install server.py --name "My Analytics Server"
348
-
349
- # Environment variables
350
- mcp install server.py -v API_KEY=abc123 -v DB_URL=postgres://...
351
- mcp install server.py -f .env
352
- ```
353
-
354
- ### Direct Execution
355
-
356
- For advanced scenarios like custom deployments:
357
-
358
- ```python
359
- from mcp.server.fastmcp import FastMCP
360
-
361
- mcp = FastMCP("My App")
362
-
363
- if __name__ == "__main__":
364
- mcp.run()
365
- ```
366
-
367
- Run it with:
368
- ```bash
369
- python server.py
370
- # or
371
- mcp run server.py
372
- ```
373
-
374
- ### Mounting to an Existing ASGI Server
375
-
376
- You can mount the SSE server to an existing ASGI server using the `sse_app` method. This allows you to integrate the SSE server with other ASGI applications.
377
-
378
- ```python
379
- from starlette.applications import Starlette
380
- from starlette.routing import Mount, Host
381
- from mcp.server.fastmcp import FastMCP
382
-
383
-
384
- mcp = FastMCP("My App")
385
-
386
- # Mount the SSE server to the existing ASGI server
387
- app = Starlette(
388
- routes=[
389
- Mount('/', app=mcp.sse_app()),
390
- ]
391
- )
392
-
393
- # or dynamically mount as host
394
- app.router.routes.append(Host('mcp.acme.corp', app=mcp.sse_app()))
395
- ```
396
-
397
- For more information on mounting applications in Starlette, see the [Starlette documentation](https://www.starlette.io/routing/#submounting-routes).
398
-
399
- ## Examples
400
-
401
- ### Echo Server
402
-
403
- A simple server demonstrating resources, tools, and prompts:
404
-
405
- ```python
406
- from mcp.server.fastmcp import FastMCP
407
-
408
- mcp = FastMCP("Echo")
409
-
410
-
411
- @mcp.resource("echo://{message}")
412
- def echo_resource(message: str) -> str:
413
- """Echo a message as a resource"""
414
- return f"Resource echo: {message}"
415
-
416
-
417
- @mcp.tool()
418
- def echo_tool(message: str) -> str:
419
- """Echo a message as a tool"""
420
- return f"Tool echo: {message}"
421
-
422
-
423
- @mcp.prompt()
424
- def echo_prompt(message: str) -> str:
425
- """Create an echo prompt"""
426
- return f"Please process this message: {message}"
427
- ```
428
-
429
- ### SQLite Explorer
430
-
431
- A more complex example showing database integration:
432
-
433
- ```python
434
- import sqlite3
435
-
436
- from mcp.server.fastmcp import FastMCP
437
-
438
- mcp = FastMCP("SQLite Explorer")
439
-
440
-
441
- @mcp.resource("schema://main")
442
- def get_schema() -> str:
443
- """Provide the database schema as a resource"""
444
- conn = sqlite3.connect("database.db")
445
- schema = conn.execute("SELECT sql FROM sqlite_master WHERE type='table'").fetchall()
446
- return "\n".join(sql[0] for sql in schema if sql[0])
447
-
448
-
449
- @mcp.tool()
450
- def query_data(sql: str) -> str:
451
- """Execute SQL queries safely"""
452
- conn = sqlite3.connect("database.db")
453
- try:
454
- result = conn.execute(sql).fetchall()
455
- return "\n".join(str(row) for row in result)
456
- except Exception as e:
457
- return f"Error: {str(e)}"
458
- ```
459
-
460
- ## Advanced Usage
461
-
462
- ### Low-Level Server
463
-
464
- For more control, you can use the low-level server implementation directly. This gives you full access to the protocol and allows you to customize every aspect of your server, including lifecycle management through the lifespan API:
465
-
466
- ```python
467
- from contextlib import asynccontextmanager
468
- from collections.abc import AsyncIterator
469
-
470
- from fake_database import Database # Replace with your actual DB type
471
-
472
- from mcp.server import Server
473
-
474
-
475
- @asynccontextmanager
476
- async def server_lifespan(server: Server) -> AsyncIterator[dict]:
477
- """Manage server startup and shutdown lifecycle."""
478
- # Initialize resources on startup
479
- db = await Database.connect()
480
- try:
481
- yield {"db": db}
482
- finally:
483
- # Clean up on shutdown
484
- await db.disconnect()
485
-
486
-
487
- # Pass lifespan to server
488
- server = Server("example-server", lifespan=server_lifespan)
489
-
490
-
491
- # Access lifespan context in handlers
492
- @server.call_tool()
493
- async def query_db(name: str, arguments: dict) -> list:
494
- ctx = server.request_context
495
- db = ctx.lifespan_context["db"]
496
- return await db.query(arguments["query"])
497
- ```
498
-
499
- The lifespan API provides:
500
- - A way to initialize resources when the server starts and clean them up when it stops
501
- - Access to initialized resources through the request context in handlers
502
- - Type-safe context passing between lifespan and request handlers
503
-
504
- ```python
505
- import mcp.server.stdio
506
- import mcp.types as types
507
- from mcp.server.lowlevel import NotificationOptions, Server
508
- from mcp.server.models import InitializationOptions
509
-
510
- # Create a server instance
511
- server = Server("example-server")
512
-
513
-
514
- @server.list_prompts()
515
- async def handle_list_prompts() -> list[types.Prompt]:
516
- return [
517
- types.Prompt(
518
- name="example-prompt",
519
- description="An example prompt template",
520
- arguments=[
521
- types.PromptArgument(
522
- name="arg1", description="Example argument", required=True
523
- )
524
- ],
525
- )
526
- ]
527
-
528
-
529
- @server.get_prompt()
530
- async def handle_get_prompt(
531
- name: str, arguments: dict[str, str] | None
532
- ) -> types.GetPromptResult:
533
- if name != "example-prompt":
534
- raise ValueError(f"Unknown prompt: {name}")
535
-
536
- return types.GetPromptResult(
537
- description="Example prompt",
538
- messages=[
539
- types.PromptMessage(
540
- role="user",
541
- content=types.TextContent(type="text", text="Example prompt text"),
542
- )
543
- ],
544
- )
545
-
546
-
547
- async def run():
548
- async with mcp.server.stdio.stdio_server() as (read_stream, write_stream):
549
- await server.run(
550
- read_stream,
551
- write_stream,
552
- InitializationOptions(
553
- server_name="example",
554
- server_version="0.1.0",
555
- capabilities=server.get_capabilities(
556
- notification_options=NotificationOptions(),
557
- experimental_capabilities={},
558
- ),
559
- ),
560
- )
561
-
562
-
563
- if __name__ == "__main__":
564
- import asyncio
565
-
566
- asyncio.run(run())
567
- ```
568
-
569
- ### Writing MCP Clients
570
-
571
- The SDK provides a high-level client interface for connecting to MCP servers:
572
-
573
- ```python
574
- from mcp import ClientSession, StdioServerParameters, types
575
- from mcp.client.stdio import stdio_client
576
-
577
- # Create server parameters for stdio connection
578
- server_params = StdioServerParameters(
579
- command="python", # Executable
580
- args=["example_server.py"], # Optional command line arguments
581
- env=None, # Optional environment variables
582
- )
583
-
584
-
585
- # Optional: create a sampling callback
586
- async def handle_sampling_message(
587
- message: types.CreateMessageRequestParams,
588
- ) -> types.CreateMessageResult:
589
- return types.CreateMessageResult(
590
- role="assistant",
591
- content=types.TextContent(
592
- type="text",
593
- text="Hello, world! from model",
594
- ),
595
- model="gpt-3.5-turbo",
596
- stopReason="endTurn",
597
- )
598
-
599
-
600
- async def run():
601
- async with stdio_client(server_params) as (read, write):
602
- async with ClientSession(
603
- read, write, sampling_callback=handle_sampling_message
604
- ) as session:
605
- # Initialize the connection
606
- await session.initialize()
607
-
608
- # List available prompts
609
- prompts = await session.list_prompts()
610
-
611
- # Get a prompt
612
- prompt = await session.get_prompt(
613
- "example-prompt", arguments={"arg1": "value"}
614
- )
615
-
616
- # List available resources
617
- resources = await session.list_resources()
618
-
619
- # List available tools
620
- tools = await session.list_tools()
621
-
622
- # Read a resource
623
- content, mime_type = await session.read_resource("file://some/path")
624
-
625
- # Call a tool
626
- result = await session.call_tool("tool-name", arguments={"arg1": "value"})
627
-
628
-
629
- if __name__ == "__main__":
630
- import asyncio
631
-
632
- asyncio.run(run())
633
- ```
634
-
635
- ### MCP Primitives
636
-
637
- The MCP protocol defines three core primitives that servers can implement:
638
-
639
- | Primitive | Control | Description | Example Use |
640
- |-----------|-----------------------|-----------------------------------------------------|------------------------------|
641
- | Prompts | User-controlled | Interactive templates invoked by user choice | Slash commands, menu options |
642
- | Resources | Application-controlled| Contextual data managed by the client application | File contents, API responses |
643
- | Tools | Model-controlled | Functions exposed to the LLM to take actions | API calls, data updates |
644
-
645
- ### Server Capabilities
646
-
647
- MCP servers declare capabilities during initialization:
648
-
649
- | Capability | Feature Flag | Description |
650
- |-------------|------------------------------|------------------------------------|
651
- | `prompts` | `listChanged` | Prompt template management |
652
- | `resources` | `subscribe`<br/>`listChanged`| Resource exposure and updates |
653
- | `tools` | `listChanged` | Tool discovery and execution |
654
- | `logging` | - | Server logging configuration |
655
- | `completion`| - | Argument completion suggestions |
656
-
657
- ## Documentation
658
-
659
- - [Model Context Protocol documentation](https://modelcontextprotocol.io)
660
- - [Model Context Protocol specification](https://spec.modelcontextprotocol.io)
661
- - [Officially supported servers](https://github.com/modelcontextprotocol/servers)
662
-
663
- ## Contributing
664
-
665
- We are passionate about supporting contributors of all levels of experience and would love to see you get involved in the project. See the [contributing guide](CONTRIBUTING.md) to get started.
666
-
667
- ## License
668
-
669
- This project is licensed under the MIT License - see the LICENSE file for details.
670
-
671
- # 知网搜索MCP服务器
672
-
673
- 该MCP服务器可以帮助您打开Chrome浏览器访问中国知网,并提供搜索功能。
674
-
675
- ## 功能
676
-
677
- - 打开Chrome浏览器访问知网
678
- - 提供搜索指定关键词的工具
679
- - 包含常见关键词搜索的提示
680
- - 允许用户保存笔记
681
-
682
- ## 安装
683
-
684
- 确保您已安装Python 3.13或更高版本,然后执行以下命令安装:
685
-
686
- ```bash
687
- uv add "mcp[cli]"
688
- ```
689
-
690
- ## 安装Playwright(推荐)
691
-
692
- 为了实现自动填写搜索框和点击搜索按钮的功能,建议安装Playwright:
693
-
694
- ```bash
695
- # 安装playwright库
696
- uv add playwright
697
-
698
- # 安装playwright浏览器
699
- playwright install
700
- ```
701
-
702
- 如果不安装Playwright,搜索功能将仅打开知网页面而不会自动输入关键词。
703
-
704
- ## 开发模式运行
705
-
706
- 使用MCP Inspector测试和调试服务器:
707
-
708
- ```bash
709
- mcp dev src/cnks/server.py
710
- ```
711
-
712
- ## 安装到Claude Desktop
713
-
714
- 准备好后,将其安装到Claude Desktop:
715
-
716
- ```bash
717
- mcp install src/cnks/server.py --name "知网搜索助手"
718
- ```
719
-
720
- ## 在Cursor中连接
721
-
722
- 要在Cursor中成功连接到服务器,请按照以下步骤操作:
723
-
724
- 1. 确保使用Python 3.13或更高版本
725
- 2. 正确安装了所有依赖:`uv add "mcp[cli]"`
726
- 3. 在终端中直接启动服务器:
727
- ```bash
728
- python -m cnks
729
- ```
730
- 4. 在Cursor中使用MCP连接功能,选择"Connect to Server"
731
-
732
- 如果出现连接问题,可以尝试:
733
- - 检查防火墙设置
734
- - 确保没有其他程序占用相同端口
735
- - 重启Cursor和服务器
736
- - 确保使用最新版本的MCP
737
-
738
- ## 使用方法
739
-
740
- ### 资源
741
-
742
- 服务器提供以下资源:
743
-
744
- - `webpage://current` - 当前打开的网页内容
745
- - `webpage://cnki/search` - 中国知网搜索页面
746
- - `note://internal/{name}` - 用户保存的笔记
747
-
748
- ### 工具
749
-
750
- 服务器提供以下工具:
751
-
752
- - `open-cnki` - 打开中国知网搜索页面
753
- - `search-keywords` - 在知网搜索关键词
754
- - `add-note` - 添加笔记
755
-
756
- ### 提示
757
-
758
- 服务器提供以下提示模板:
759
-
760
- - `search-literature` - 按主题搜索文献
761
- - `advanced-search` - 高级文献搜索
762
- - `summarize-notes` - 总结所有笔记
763
-
764
- ## 示例用法
765
-
766
- ### 打开知网
767
-
768
- ```
769
- 请打开中国知网搜索页面
770
- ```
771
-
772
- ### 搜索关键词
773
-
774
- ```
775
- 请在知网搜索"人工智能教育应用"相关论文
776
- ```
777
-
778
- ### 添加笔记
779
-
780
- ```
781
- 请添加一个笔记,名称为"AI教育论文",内容为"人工智能在教育中的应用研究进展"
782
- ```
783
-
784
- ### 使用高级搜索
785
-
786
- ```
787
- 请使用高级搜索,查找标题包含"教育科技"、作者为"张三"的论文
788
- ```
789
-
790
- ## 故障排除
791
-
792
- ### Chrome未找到
793
-
794
- 系统会自动在常见位置查找Chrome浏览器。如果遇到"未找到Chrome可执行文件"错误,可以通过设置环境变量来指定Chrome位置:
795
-
796
- #### Windows
797
-
798
- ```cmd
799
- set CHROME_PATH="C:\你的Chrome路径\chrome.exe"
800
- ```
801
-
802
- #### macOS/Linux
803
-
804
- ```bash
805
- export CHROME_PATH="/path/to/chrome"
806
- ```
807
-
808
- 或者你也可以直接修改`server.py`文件中的Chrome检测代码,添加你的Chrome位置。
809
-
810
- ### Playwright相关问题
811
-
812
- 如果在使用Playwright时遇到问题:
813
-
814
- ```bash
815
- # 确保playwright库已安装
816
- uv add playwright
817
-
818
- # 安装所需浏览器
819
- playwright install
820
-
821
- # 如果上述命令无效,可能需要管理员权限
822
- ```
823
-
824
- ### 连接问题
825
-
826
- 如果在Cursor中连接服务器时遇到问题:
827
-
828
- 1. 尝试重启服务器和Cursor
829
- 2. 确认使用正确的连接方式(stdio或SSE)
830
- 3. 检查服务器日志输出是否有错误信息
831
- 4. 确保MCP依赖已正确安装:`uv add "mcp[cli]" --upgrade`
832
-
833
- ### 其他常见问题
834
-
835
- - **中文字符显示问题**:确保使用UTF-8编码
836
- - **权限错误**:在Windows上可能需要以管理员身份运行
837
- - **网络访问受限**:确保Chrome可以访问互联网
838
-
839
- ## 许可证
840
-
841
- 本项目使用MIT许可证 - 详情见LICENSE文件。