Skip to main content
Glama
Rainmen-xia

Chrome Debug MCP Server

by Rainmen-xia

navigate_to

Navigate Chrome to a specified URL, intelligently reusing existing tabs for the same domain to manage browser sessions efficiently.

Instructions

导航到指定URL,智能管理标签页(相同域名复用标签页)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes要导航到的URL

Implementation Reference

  • The core handler function implementing 'navigate_to' logic: intelligently navigates to the given URL by reusing existing tabs for the same root domain or creating new ones, with robust loading waits and error handling.
    async navigateToUrl(url: string): Promise<BrowserActionResult> {
    	if (!this.browser) {
    		return {
    			success: false,
    			error: "浏览器未启动"
    		};
    	}
    
    	// 移除尾部斜杠进行比较
    	const normalizedNewUrl = url.replace(/\/$/, "");
    
    	// 从URL中提取根域名
    	const rootDomain = this.getRootDomain(normalizedNewUrl);
    
    	// 获取所有当前页面
    	const pages = await this.browser.pages();
    
    	// 尝试找到具有相同根域名的页面
    	let existingPage: Page | undefined;
    
    	for (const page of pages) {
    		try {
    			const pageUrl = page.url();
    			if (pageUrl && this.getRootDomain(pageUrl) === rootDomain) {
    				existingPage = page;
    				break;
    			}
    		} catch (error) {
    			// 跳过可能已关闭或有错误的页面
    			console.log(`检查页面URL时出错: ${error}`);
    			continue;
    		}
    	}
    
    	if (existingPage) {
    		// 存在具有相同根域名的标签页,切换到它
    		console.log(`域名 ${rootDomain} 的标签页已存在,切换到它`);
    
    		// 更新活动页面
    		this.page = existingPage;
    		existingPage.bringToFront();
    
    		// 如果URL不同则导航到新URL
    		const currentUrl = existingPage.url().replace(/\/$/, ""); // 如果存在,移除尾部/
    		if (this.getRootDomain(currentUrl) === rootDomain && currentUrl !== normalizedNewUrl) {
    			console.log(`导航到新URL: ${normalizedNewUrl}`);
    			// 导航到新URL
    			return this.doAction(async (page) => {
    				await this.navigatePageToUrl(page, normalizedNewUrl);
    			});
    		} else {
    			console.log(`域名 ${rootDomain} 的标签页已存在,且URL相同: ${normalizedNewUrl}`);
    			// URL相同,只需重新加载页面以确保它是最新的
    			console.log(`重新加载页面: ${normalizedNewUrl}`);
    			return this.doAction(async (page) => {
    				await page.reload({ 
    					timeout: 15_000, 
    					waitUntil: ["domcontentloaded", "networkidle2"] 
    				}).catch(async (error) => {
    					// 如果networkidle2失败,尝试仅等待domcontentloaded
    					console.log(`重新加载网络静默等待失败,尝试仅等待DOM: ${error.message}`);
    					await page.reload({ 
    						timeout: 15_000, 
    						waitUntil: ["domcontentloaded"] 
    					});
    				});
    				await this.waitTillHTMLStable(page);
    			});
    		}
    	} else {
    		// 不存在此根域名的标签页,创建新的
    		console.log(`域名 ${rootDomain} 的标签页不存在,创建新的`);
    		return this.createNewTab(normalizedNewUrl);
    	}
    }
  • The input schema and metadata for the 'navigate_to' tool, defining it requires a 'url' string parameter.
    {
    	name: "navigate_to",
    	description: "导航到指定URL,智能管理标签页(相同域名复用标签页)",
    	inputSchema: {
    		type: "object",
    		properties: {
    			url: {
    				type: "string",
    				description: "要导航到的URL",
    			},
    		},
    		required: ["url"],
    	},
    },
  • src/index.ts:182-187 (registration)
    Registration and dispatching logic in the CallToolRequestSchema handler: validates input and calls the browserSession.navigateToUrl method.
    case "navigate_to":
    	if (!args?.url) {
    		throw new Error("URL参数是必需的");
    	}
    	result = await this.browserSession.navigateToUrl(args.url as string);
    	break;
  • src/index.ts:44-164 (registration)
    Tool registration in ListToolsRequestSchema handler, where 'navigate_to' is listed among available tools with its schema.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => {
    	return {
    		tools: [
    			{
    				name: "launch_browser",
    				description: "启动浏览器连接,连接到Chrome调试端口以保持登录状态",
    				inputSchema: {
    					type: "object",
    					properties: {
    						remote_host: {
    							type: "string",
    							description: "可选的远程Chrome主机URL (例如: http://localhost:9222)",
    						},
    					},
    				},
    			},
    			{
    				name: "close_browser",
    				description: "关闭浏览器连接",
    				inputSchema: {
    					type: "object",
    					properties: {},
    				},
    			},
    			{
    				name: "navigate_to",
    				description: "导航到指定URL,智能管理标签页(相同域名复用标签页)",
    				inputSchema: {
    					type: "object",
    					properties: {
    						url: {
    							type: "string",
    							description: "要导航到的URL",
    						},
    					},
    					required: ["url"],
    				},
    			},
    			{
    				name: "click",
    				description: "在指定坐标位置点击",
    				inputSchema: {
    					type: "object",
    					properties: {
    						coordinate: {
    							type: "string",
    							description: "点击位置的坐标,格式为 'x,y'",
    						},
    					},
    					required: ["coordinate"],
    				},
    			},
    			{
    				name: "type_text",
    				description: "输入文本内容",
    				inputSchema: {
    					type: "object",
    					properties: {
    						text: {
    							type: "string",
    							description: "要输入的文本内容",
    						},
    					},
    					required: ["text"],
    				},
    			},
    			{
    				name: "scroll_down",
    				description: "向下滚动页面一个视口高度",
    				inputSchema: {
    					type: "object",
    					properties: {},
    				},
    			},
    			{
    				name: "scroll_up",
    				description: "向上滚动页面一个视口高度",
    				inputSchema: {
    					type: "object",
    					properties: {},
    				},
    			},
    			{
    				name: "hover",
    				description: "将鼠标悬停在指定坐标位置",
    				inputSchema: {
    					type: "object",
    					properties: {
    						coordinate: {
    							type: "string",
    							description: "悬停位置的坐标,格式为 'x,y'",
    						},
    					},
    					required: ["coordinate"],
    				},
    			},
    			{
    				name: "resize_browser",
    				description: "调整浏览器窗口大小",
    				inputSchema: {
    					type: "object",
    					properties: {
    						size: {
    							type: "string",
    							description: "窗口大小,格式为 'width,height'",
    						},
    					},
    					required: ["size"],
    				},
    			},
    			{
    				name: "get_page_content",
    				description: "获取当前页面的HTML内容",
    				inputSchema: {
    					type: "object",
    					properties: {},
    				},
    			},
    		] as Tool[],
    	};
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions '智能管理标签页(相同域名复用标签页)' which reveals the tab reuse behavior - a valuable behavioral trait. However, it doesn't disclose other important aspects: whether this opens a new browser if none exists, what happens with invalid URLs, authentication requirements, timeout behavior, or what constitutes successful navigation. For a navigation tool with zero annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise - just one Chinese sentence with two clauses. The first clause states the core purpose, the second adds important behavioral context about tab management. Every word earns its place with zero redundancy or fluff. It's front-loaded with the primary function.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a navigation tool with no annotations and no output schema, the description is incomplete. While it mentions the tab reuse behavior, it doesn't cover: what happens if no browser is open, error conditions, timeout behavior, success indicators, or relationship to other browser tools. The agent lacks sufficient context to use this tool effectively in various scenarios.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage with a clear parameter description for 'url'. The tool description doesn't add any parameter-specific information beyond what's in the schema. It doesn't elaborate on URL format requirements, validation rules, or special handling. With complete schema coverage, the baseline of 3 is appropriate as the description doesn't enhance parameter understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: '导航到指定URL' (navigate to specified URL) and adds '智能管理标签页(相同域名复用标签页)' (intelligently manage tabs - reuse tabs with same domain). This specifies both the action (navigate) and resource (URL/tabs), though it doesn't explicitly differentiate from sibling tools like 'launch_browser' or 'get_page_content'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no explicit guidance on when to use this tool versus alternatives. While '智能管理标签页' hints at tab reuse behavior, it doesn't specify when to choose this over 'launch_browser' for initial navigation or how it relates to other navigation/interaction tools. No prerequisites, exclusions, or comparison to siblings are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

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/Rainmen-xia/chrome-debug-mcp'

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